3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ary_main = array( array( "name" => "PSGR004"), array( "name" => "HRCO005"), array( "name" => "HRCO055"), array( "name" => "SAGR110"), array( "name" => "SAGR105"), array( "name" => "SAGR105"), array( "name" => "MAPR161"), array( "name" => "SAGR184") ); $args[] = array(3,4,6,2,0,1,6,1); $args[] = SORT_ASC; $args[] = array("psgr040","hrco055","hrco055","sagr110","sagr105","sagr105","mapr161","sagr184"); $args[] = SORT_DESC; $args[] =& $ary_main; call_user_func_array("array_multisort", $args); foreach($ary_main as $ary) { echo $ary["name"],"\n"; } echo "\n-----------\n"; array_multisort($args[0], $args[1], $args[2], $args[3], $args[4]); foreach($ary_main as $ary) { echo $ary["name"],"\n"; }
Output for 5.2.0 - 5.2.17, 5.3.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.7 - 7.1.0
SAGR105 SAGR184 SAGR105 SAGR110 PSGR004 HRCO005 MAPR161 HRCO055 ----------- PSGR004 HRCO055 HRCO005 SAGR110 SAGR105 SAGR184 MAPR161 SAGR105
Output for 4.3.0 - 5.1.6, 7.0.0 - 7.0.6
SAGR105 SAGR184 SAGR105 SAGR110 PSGR004 HRCO005 MAPR161 HRCO055 ----------- SAGR105 SAGR184 SAGR105 SAGR110 PSGR004 HRCO005 MAPR161 HRCO055
Output for 5.3.0 - 5.3.3
Warning: Parameter 1 to array_multisort() expected to be a reference, value given in /in/lJVk4 on line 22 PSGR004 HRCO005 HRCO055 SAGR110 SAGR105 SAGR105 MAPR161 SAGR184 ----------- SAGR105 SAGR184 SAGR105 SAGR110 PSGR004 HRCO005 MAPR161 HRCO055