Last active
January 14, 2019 12:55
-
-
Save Luxato/7d4c48cb6bff3e7f2fde18ec89e5509a to your computer and use it in GitHub Desktop.
Move array element to different position within the array.
This file contains hidden or 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 | |
function moveElement(&$array, $a, $b) { | |
$out = array_splice($array, $a, 1); | |
array_splice($array, $b, 0, $out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment