3v4l.org

run code in 300+ PHP versions simultaneously
<?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 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
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.1.6, 5.2.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.3.11, 4.4.0 - 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.

preferences:
262.56 ms | 401 KiB | 368 Q