Created
October 28, 2015 16:12
-
-
Save blar/39de4860015e494e2b9e to your computer and use it in GitHub Desktop.
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 | |
$array = array( | |
'foo' => 23, | |
'bar' => 42, | |
'foobar' => 1337 | |
); | |
$order = array('foo', 'foobar', 'bar'); | |
uksort($array, function($foo, $bar) use($order) { | |
return array_search($foo, $fields) > array_search($bar, $fields); | |
}); | |
var_dump($array); | |
array(3) { | |
["foo"]=> | |
int(23) | |
["foobar"]=> | |
int(1337) | |
["bar"]=> | |
int(42) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment