Created
April 2, 2014 03:18
-
-
Save dinolatoga/9927398 to your computer and use it in GitHub Desktop.
Move Arrays on top or bottom
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
function move_to_top(&$array, $key) { | |
$temp = array($key => $array[$key]); | |
unset($array[$key]); | |
$array = $temp + $array; | |
} | |
function move_to_bottom(&$array, $key) { | |
$value = $array[$key]; | |
unset($array[$key]); | |
$array[$key] = $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment