3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $json = json_decode('[ { "Date":"2014-12-29", "totalCount":"1" }, { "Date":"2015-02-05", "totalCount":"116" }, { "Date":"2015-02-06", "totalCount":"7" }, { "Date":"2015-02-07", "totalCount":"5" }, { "Date":"2015-02-08", "totalCount":"16" }, { "Date":"2015-02-09", "totalCount":"39" }, { "Date":"2015-02-10", "totalCount":"29" }, { "Date":"2015-02-11", "totalCount":"7" }, { "Date":"2015-02-12", "totalCount":"14" }, { "Date":"2015-02-13", "totalCount":"16" }, { "Date":"2015-02-14", "totalCount":"12" }, { "Date":"2015-02-15", "totalCount":"7" }, { "Date":"2015-02-16", "totalCount":"1" }, { "Date":"2015-02-17", "totalCount":"8" }, { "Date":"2015-02-18", "totalCount":"25" }, { "Date":"2015-02-19", "totalCount":"17" }, { "Date":"2015-02-20", "totalCount":"15" }, { "Date":"2015-02-21", "totalCount":"10" }, { "Date":"2015-02-22", "totalCount":"7" }, { "Date":"2015-02-23", "totalCount":"8" }, { "Date":"2015-02-24", "totalCount":"17" }, { "Date":"2015-02-25", "totalCount":"3" }, { "Date":"2015-02-26", "totalCount":"3" }, { "Date":"2015-02-27", "totalCount":"2" }, { "Date":"2015-02-28", "totalCount":"1" }, { "Date":"2015-03-01", "totalCount":"3" }, { "Date":"2015-03-02", "totalCount":"10" }, { "Date":"2015-03-03", "totalCount":"1" }, { "Date":"2015-03-04", "totalCount":"9" }, { "Date":"2015-03-05", "totalCount":"3" }, { "Date":"2015-03-06", "totalCount":"13" }, { "Date":"2015-03-07", "totalCount":"5" }, { "Date":"2015-03-08", "totalCount":"7" }, { "Date":"2015-03-09", "totalCount":"6" }, { "Date":"2015-03-10", "totalCount":"11" }, { "Date":"2015-03-11", "totalCount":"3" }, { "Date":"2015-03-12", "totalCount":"8" }, { "Date":"2015-03-13", "totalCount":"5" }, { "Date":"2015-03-14", "totalCount":"10" }, { "Date":"2015-03-15", "totalCount":"5" }, { "Date":"2015-03-16", "totalCount":"5" }, { "Date":"2015-03-17", "totalCount":"7" }, { "Date":"2015-03-18", "totalCount":"4" }, { "Date":"2015-03-19", "totalCount":"4" }, { "Date":"2015-03-20", "totalCount":"6" }, { "Date":"2015-03-21", "totalCount":"6" }, { "Date":"2015-03-22", "totalCount":"2" }, { "Date":"2015-03-23", "totalCount":"3" }, { "Date":"2015-03-24", "totalCount":"7" }, { "Date":"2015-03-25", "totalCount":"5" }, { "Date":"2015-03-26", "totalCount":"2" }, { "Date":"2015-03-27", "totalCount":"2" }, { "Date":"2015-03-28", "totalCount":"4" }, { "Date":"2015-03-29", "totalCount":"3" }, { "Date":"2015-03-30", "totalCount":"3" }, { "Date":"2015-03-31", "totalCount":"1" }, { "Date":"2015-04-01", "totalCount":"3" }, { "Date":"2015-04-02", "totalCount":"5" }, { "Date":"2015-04-03", "totalCount":"5" }, { "Date":"2015-04-04", "totalCount":"3" }, { "Date":"2015-04-05", "totalCount":"4" }, { "Date":"2015-04-06", "totalCount":"2" }, { "Date":"2015-04-07", "totalCount":"4" }, { "Date":"2015-04-08", "totalCount":"7" }, { "Date":"2015-04-09", "totalCount":"5" }, { "Date":"2015-04-10", "totalCount":"3" }, { "Date":"2015-04-11", "totalCount":"7" }, { "Date":"2015-04-12", "totalCount":"5" }, { "Date":"2015-04-13", "totalCount":"12" }, { "Date":"2015-04-14", "totalCount":"5" }, { "Date":"2015-04-15", "totalCount":"7" }, { "Date":"2015-04-16", "totalCount":"5" }, { "Date":"2015-04-17", "totalCount":"6" }, { "Date":"2015-04-18", "totalCount":"6" }, { "Date":"2015-04-19", "totalCount":"14" }, { "Date":"2015-04-20", "totalCount":"10" }, { "Date":"2015-04-21", "totalCount":"10" }, { "Date":"2015-04-22", "totalCount":"4" }, { "Date":"2015-04-23", "totalCount":"7" }, { "Date":"2015-04-24", "totalCount":"8" } ]'); $total = 0; foreach ($json as $key => $obj) { $total += intval($obj->totalCount); } var_dump($total);
based on Tn7Un
Output for 5.2.0 - 7.2.0
int(696)
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/sqOg4 on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/sqOg4 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/sqOg4 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/sqOg4 on line 3