3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $json = '{ "categories":{ "sermons":[ { "title":"We Have Overcome the World" , "url":"http://test.solidrockchristianfellowship.com/sermons/we-have-overcome-the-world/" , "content":"" , "date":"May 22, 2014", "datetime":"2014-05-22T13:41:49", } ], "events":[ { "title":"SRCF Night of Prayer" , "url":"http://test.solidrockchristianfellowship.com/events/srcf-night-of-prayer/" , "content":"<p>Apr 4th at 7:30 pm SRCF Night of Prayer, Praise and the Word; Guest Speaker is Pastor Shirley Reid; Shekinah Glory Ministry; N. Charleston, SC</p>" , "date":"April 04, 2014", "datetime":"2014-04-04T00:00:00", }, { "title":"Mighty Warrior" , "url":"http://test.solidrockchristianfellowship.com/events/mighty-warrior/" , "content":"" , "date":"April 19, 2014", "datetime":"2014-04-19T00:00:00", }, { "title":"Solid Rock Spring Revival" , "url":"http://test.solidrockchristianfellowship.com/events/solid-rock-spring-revival/" , "content":"<p>SRCF Spring Revival; Guest Speaker is Apostle W. Lenard King; Pastor of New Covenant Evangelistic Center; Charleston, SC</p>" , "date":"April 23, 2014", "datetime":"2014-04-23T00:00:00", } ] }, "pages":{ "About Us": { "title":"About Us" , "url":"http://test.solidrockchristianfellowship.com/about-us/" }, "Bible Study with Pastor Faden": { "title":"Bible Study with Pastor Faden" , "url":"http://test.solidrockchristianfellowship.com/bible-study-with-pastor-faden/" }, "Live Stream": { "title":"Live Stream" , "url":"http://test.solidrockchristianfellowship.com/live-stream/" }, "Our Ministries": { "title":"Our Ministries" , "url":"http://test.solidrockchristianfellowship.com/our-ministries/" }, "Our Mission": { "title":"Our Mission" , "url":"http://test.solidrockchristianfellowship.com/our-mission/" }, "Our Pastor": { "title":"Our Pastor" , "url":"http://test.solidrockchristianfellowship.com/our-pastor/" }, "Our Vision": { "title":"Our Vision" , "url":"http://test.solidrockchristianfellowship.com/our-vision/" }, "Prayer Request": { "title":"Prayer Request" , "url":"http://test.solidrockchristianfellowship.com/prayer-request/" }, "Service Times": { "title":"Service Times" , "url":"http://test.solidrockchristianfellowship.com/service-times/" }, "Subscribe": { "title":"Subscribe" , "url":"http://test.solidrockchristianfellowship.com/subscribe/" }, "Videos": { "title":"Videos" , "url":"http://test.solidrockchristianfellowship.com/videos/" }, "What we Believe": { "title":"What we Believe" , "url":"http://test.solidrockchristianfellowship.com/what-we-believe/" } } } '; function test($jsondata){ // decode the json data for parsing $json = json_decode($jsondata, true); var_dump(json_last_error()); $todaysDate = date("Y-m-d"); $data = $json['categories']['events'] ; foreach($data as $event) { echo '<li>'; echo $event['title']; echo $event['date']; echo $event['datetime']; echo '</li>'; } } ?> <pre><?php var_dump(test($json));?></pre>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
<pre>int(4) Warning: Invalid argument supplied for foreach() in /in/EXrbH on line 112 NULL </pre>
Output for hhvm-3.12.0
<pre>int(4) Warning: Invalid argument supplied for foreach() in /in/EXrbH on line 118 NULL </pre>
Output for hhvm-3.10.0
<pre>int(4) Warning: Invalid argument supplied for foreach() in /in/EXrbH on line -1 NULL </pre>
Output for 5.2.0 - 5.2.17
<pre> Fatal error: Call to undefined function json_last_error() in /in/EXrbH on line 108
Process exited with code 255.
Output for 5.0.0 - 5.1.6
<pre> Fatal error: Call to undefined function json_decode() in /in/EXrbH on line 106
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<pre> Fatal error: Call to undefined function: json_decode() in /in/EXrbH on line 106
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<pre> Fatal error: Call to undefined function: json_decode() in /in/EXrbH on line 106
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<pre> Fatal error: Call to undefined function: json_decode() in /in/EXrbH on line 106