Last active
October 19, 2022 19:33
-
-
Save masiur/e8cdd7f410ed4101bfd55c83cf0356e3 to your computer and use it in GitHub Desktop.
swap between php array (move to left ) using splice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// take out the target element from array, $key is the target element index number , 1 means 1 element | |
$arraySpliced = array_splice($stages, $key, 1); | |
// adding the spliced element to the previous index of $key and 0 means extract or slice no element. | |
$arraySpliced = array_splice($stages, $key-1, 0, $arraySpliced); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example