3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( 'ACTION' => 'getsupportdepartments', 'RESULT' => 'success', 'TOTALRESULTS' => 2, 'DEPARTMENTS' => array( 'DEPARTMENT' => array( 'ID' => 2, 'NAME' => 'Sales', 'AWAITINGREPLY' => 5, 'OPENTICKETS' => 5 ), 'DEPARTMENT1' => array( 'ID' => 1, 'NAME' => 'Support', 'AWAITINGREPLY' => 15, 'OPENTICKETS' => 15))); function sortDepts(array &$arr,$sort="desc") { function asc($a,$b) { return $a["AWAITINGREPLY"]-$b["AWAITINGREPLY"]; } function desc($a,$b) { return $b["AWAITINGREPLY"]-$a["AWAITINGREPLY"]; } if($sort=="desc") usort($arr["DEPARTMENTS"],"desc"); else usort($arr["DEPARTMENTS"],"asc"); return $arr; } print_r(sortDepts($arr,"desc")); print_r(sortDepts($arr,"asc"));
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [ACTION] => getsupportdepartments [RESULT] => success [TOTALRESULTS] => 2 [DEPARTMENTS] => Array ( [0] => Array ( [ID] => 1 [NAME] => Support [AWAITINGREPLY] => 15 [OPENTICKETS] => 15 ) [1] => Array ( [ID] => 2 [NAME] => Sales [AWAITINGREPLY] => 5 [OPENTICKETS] => 5 ) ) ) Fatal error: Cannot redeclare asc() (previously declared in /in/1sec6:20) in /in/1sec6 on line 20
Process exited with code 255.

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:
42.44 ms | 402 KiB | 8 Q