3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $abc = array( 'rec_1' => array('f_name'=>'Aron','m_i'=>'M'), 'rec_2' => array('f_name'=>'Abbey','m_i'=>'D'), 'rec_3' => array('f_name'=>'Alice','m_i'=>'P')); function build_sorter($key) { return function ($a, $b) use ($key) { return strnatcmp($a[$key], $b[$key]); }; } usort($abc, build_sorter('f_name')); foreach ($abc as $item) { echo $item['f_name'] . ', ' . $item['m_i'] . "\n"; }
based on XprpK
Output for 5.3.0 - 7.2.0
Abbey, D Alice, P Aron, M
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/50m62 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/50m62 on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/50m62 on line 8
Process exited with code 255.