3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $abc = array( array('f_name'=>'Aron','m_i'=>'M'), array('f_name'=>'Abbey','m_i'=>'D'), array('f_name'=>'Alice','m_i'=>'P')); function build_sorter($key) { return function ($a, $b) use ($key) { return strnatcmp($a[$key], $b[$key]); }; } usort($array, build_sorter('f_name')); foreach ($array as $item) { echo $item['f_name'] . ', ' . $item['m_i'] . "\n"; }
based on TFLW6
Output for 5.3.0 - 7.2.0
Warning: usort() expects parameter 1 to be array, null given in /in/HbVcM on line 13 Warning: Invalid argument supplied for foreach() in /in/HbVcM on line 15
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/HbVcM on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/HbVcM on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/HbVcM on line 8
Process exited with code 255.