3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createMultiKeyCmpFunc($cmp, $key /* , keys... */) { $keys = func_get_args(); array_shift($keys); return function (array $a, array $b) use ($cmp, $keys) { return array_reduce($keys, function ($result, $key) use ($cmp, $a, $b) { return $result ?: call_user_func($cmp, $a[$key], $b[$key]); }); }; } $array = [ ['foo' => 4, 'bar' => 2, 'baz' => 3], ['foo' => 4, 'bar' => 3, 'baz' => 3], ['foo' => 3, 'bar' => 2, 'baz' => 3], ['foo' => 4, 'bar' => 1, 'baz' => 6], ['foo' => 3, 'bar' => 2, 'baz' => 3], ['foo' => 1, 'bar' => 4, 'baz' => 3], ['foo' => 2, 'bar' => 2, 'baz' => 1], ['foo' => 6, 'bar' => 6, 'baz' => 8], ['foo' => 6, 'bar' => 2, 'baz' => 3], ['foo' => 3, 'bar' => 1, 'baz' => 5], ['foo' => 4, 'bar' => 2, 'baz' => 3], ]; usort($array, createMultiKeyCmpFunc('strcmp', 'foo', 'bar', 'baz')); print_r($array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [foo] => 1 [bar] => 4 [baz] => 3 ) [1] => Array ( [foo] => 2 [bar] => 2 [baz] => 1 ) [2] => Array ( [foo] => 3 [bar] => 1 [baz] => 5 ) [3] => Array ( [foo] => 3 [bar] => 2 [baz] => 3 ) [4] => Array ( [foo] => 3 [bar] => 2 [baz] => 3 ) [5] => Array ( [foo] => 4 [bar] => 1 [baz] => 6 ) [6] => Array ( [foo] => 4 [bar] => 2 [baz] => 3 ) [7] => Array ( [foo] => 4 [bar] => 2 [baz] => 3 ) [8] => Array ( [foo] => 4 [bar] => 3 [baz] => 3 ) [9] => Array ( [foo] => 6 [bar] => 2 [baz] => 3 ) [10] => Array ( [foo] => 6 [bar] => 6 [baz] => 8 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
30.24 ms | 403 KiB | 8 Q