3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function sortDurations($a, $b) { if (strcmp($a['start'], $b['start']) == 0) { return 0; } else if (strcmp($a['start'], $b['start']) < 0) { return -1; } else if (strcmp($a['start'], $b['start']) > 0) { return 1; } return 0; } $tab = array(); $tab [] = array('start'=>'10:00:00','finish'=>'10:30:00'); $tab [] = array('start'=>'11:00:00','finish'=>'11:00:00'); $tab [] = array('start'=>'12:00:00','finish'=>'12:30:00'); $tab [] = array('start'=>'08:00:00','finish'=>'08:30:00'); $tab [] = array('start'=>'09:00:00','finish'=>'09:30:00'); $tab [] = array('start'=>'14:00:00','finish'=>'14:30:00'); $tab = array($tab); /**echo "avant tri <pre>"; print_r($tab); echo "</pre>"; **/ echo json_encode($tab); uasort($tab, 'sortDurations' ); echo "\r\n"; /** echo "apres tri <pre>"; var_dump($tab); echo "</pre>"; **/ echo json_encode($tab); echo "\r\n"; ?>
Output for 5.2.0 - 7.1.0
[[{"start":"10:00:00","finish":"10:30:00"},{"start":"11:00:00","finish":"11:00:00"},{"start":"12:00:00","finish":"12:30:00"},{"start":"08:00:00","finish":"08:30:00"},{"start":"09:00:00","finish":"09:30:00"},{"start":"14:00:00","finish":"14:30:00"}]] [[{"start":"10:00:00","finish":"10:30:00"},{"start":"11:00:00","finish":"11:00:00"},{"start":"12:00:00","finish":"12:30:00"},{"start":"08:00:00","finish":"08:30:00"},{"start":"09:00:00","finish":"09:30:00"},{"start":"14:00:00","finish":"14:30:00"}]]
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/5jrJB on line 35
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/5jrJB on line 35
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/5jrJB on line 35
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/5jrJB on line 35