3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $events=array(array("date"=>"20130329","title"=>"Run","cats"=>array(array("name"=>"Cause 2","slug"=>"cause-2","sort"=>1))),array("date"=>"20130131","title"=>"Run2","cats"=>array(array("name"=>"Abused Children","slug"=>"abused-children","sort"=>2),array("name"=>"Animal Welfare","slug"=>"animal-welfare","sort"=>3),array("name"=>"Education","slug"=>"education","sort"=>1)))); $events=array_map(function($arr){ usort($arr["cats"],function($a,$b){ return $a["sort"]-$b["sort"]; }); return $arr; },$events); foreach($events as $event) { echo "Event: ".$event["title"]."\n"; foreach($event["cats"] as $cat) { echo " Cat: ".$cat["name"]."\n"; } }
Output for 5.3.0 - 7.1.0
Event: Run Cat: Cause 2 Event: Run2 Cat: Education Cat: Abused Children Cat: Animal Welfare
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/qplgO on line 3
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, expecting ')' in /in/qplgO on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/qplgO on line 3
Process exited with code 255.