3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $json = <<<JSON { "api_json": [ { "api_id": 1, "api_no": 36, "api_name": "name", "api_val": [ 133, 424 ] }, { "api_id": 2, "api_no": 21, "api_name": "name2", "api_val": [ 213, 924 ] } ] } JSON; $data = json_decode($json); foreach($data['api_json'] as $row) { if ($row['api_name'] === 'name2') echo 'API Name "name2" found in api_id ', $row['api_id']; }
based on hsF4A
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/Ym275:29 Stack trace: #0 {main} thrown in /in/Ym275 on line 29
Process exited with code 255.
Output for 5.2.0 - 5.6.28
Fatal error: Cannot use object of type stdClass as array in /in/Ym275 on line 29
Process exited with code 255.
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/Ym275 on line 28
Process exited with code 255.
Output for 5.1.2
Fatal error: Call to undefined function json_decode() in /in/Ym275 on line 29
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/Ym275 on line 28
Process exited with code 255.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/Ym275 on line 28
Process exited with code 255.
Output for 4.4.2
Fatal error: Call to undefined function: json_decode() in /in/Ym275 on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/Ym275 on line 28