3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $foo[1]['items'][] = 'Third'; $foo[0]['items'][] = 'Second'; $foo[4]['items'][] = 'Last'; $foo[-1]['items'][] = 'I will be first'; $foo[0]['items'][] = 'Also second'; function cmp($a, $b) { if ($a == $b) { return 0; } return ($a > $b) ? -1 : 1; } usort($foo, "cmp"); echo '<pre>'; var_dump($foo); echo '</pre>';
Output for 4.3.0 - 7.1.0
<pre>array(4) { [0]=> array(1) { ["items"]=> array(2) { [0]=> string(6) "Second" [1]=> string(11) "Also second" } } [1]=> array(1) { ["items"]=> array(1) { [0]=> string(5) "Third" } } [2]=> array(1) { ["items"]=> array(1) { [0]=> string(4) "Last" } } [3]=> array(1) { ["items"]=> array(1) { [0]=> string(15) "I will be first" } } } </pre>