3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <calender> <task> <date>00/00/0000</date> <title>My Birthday</title> <description>Today is my birthday!</description> </task> <task> <date>04/08/2013</date> <title>test</title> <description>swdefswde</description> </task> <task> <date>04/02/2013</date> <title>test</title> <description>test</description> </task> <task> <date>04/01/2013</date> <title>egfwe</title> <description>wefwef</description> </task> <task> <date>04/03/2013</date> <title>ssdv</title> <description>ssdvs</description> </task> </calender> XML ); $arr=[]; foreach($xml->task as $aTask) { $arr[]=$aTask; } //print_r($arr); usort($arr,function($a,$b){ return strtotime($a->date)-strtotime($b->date); }); //print_r($arr); $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <calender> </calender> XML ); foreach($arr as $aTask) { $tTask=$xml->addChild($aTask->getName()); $tTask->addChild($aTask->date->getName(),(string)$aTask->date); $tTask->addChild($aTask->title->getName(),(string)$aTask->title); $tTask->addChild($aTask->description->getName(),(string)$aTask->description); } echo $xml->asXML();
Output for 5.4.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
<?xml version="1.0"?> <calender> <task><date>00/00/0000</date><title>My Birthday</title><description>Today is my birthday!</description></task><task><date>04/01/2013</date><title>egfwe</title><description>wefwef</description></task><task><date>04/02/2013</date><title>test</title><description>test</description></task><task><date>04/03/2013</date><title>ssdv</title><description>ssdvs</description></task><task><date>04/08/2013</date><title>test</title><description>swdefswde</description></task></calender>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/9BTdX on line 39
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected '[' in /in/9BTdX on line 40
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 '[' in /in/9BTdX on line 39
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/9BTdX on line 39
Process exited with code 255.