3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function sortFunction( $a, $b ) { return strtotime($a["date"]) - strtotime($b["date"]); } $data = '[{"date":"2013-09-01 00:00:02","content":"1"}, {"date":"2013-09-01 00:00:09","content":"5"}, {"date":"2013-09-01 00:00:01","content":"3"}]'; usort($data, "sortFunction"); var_dump($data);
Output for 5.3.0 - 7.1.0
Warning: usort() expects parameter 1 to be array, string given in /in/nRtiQ on line 11 string(160) "[{"date":"2013-09-01 00:00:02","content":"1"}, {"date":"2013-09-01 00:00:09","content":"5"}, {"date":"2013-09-01 00:00:01","content":"3"}]"
Output for 4.3.2 - 5.2.17
Warning: usort(): The argument should be an array in /in/nRtiQ on line 11 string(160) "[{"date":"2013-09-01 00:00:02","content":"1"}, {"date":"2013-09-01 00:00:09","content":"5"}, {"date":"2013-09-01 00:00:01","content":"3"}]"
Output for 4.3.0 - 4.3.1
Warning: usort() [http://www.php.net/function.usort]: The argument should be an array in /in/nRtiQ on line 11 string(160) "[{"date":"2013-09-01 00:00:02","content":"1"}, {"date":"2013-09-01 00:00:09","content":"5"}, {"date":"2013-09-01 00:00:01","content":"3"}]"