Skip to content

Instantly share code, notes, and snippets.

@blar
Created October 28, 2015 16:12
Show Gist options
  • Save blar/39de4860015e494e2b9e to your computer and use it in GitHub Desktop.
Save blar/39de4860015e494e2b9e to your computer and use it in GitHub Desktop.
<?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