3v4l.org

run code in 300+ PHP versions simultaneously
<?php $details='[{"percentage":"12.5","id":10},{"percentage":"35","id":12},{"percentage":"5","id":52}]'; $data=(json_decode($details)); foreach($data as $d){ if($d['id'] == 52){ print_r($d['percentage']); } }
Output for 8.1.32, 8.2.0 - 8.2.28, 8.3.0 - 8.3.19, 8.4.1 - 8.4.5
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/9vmhT:7 Stack trace: #0 {main} thrown in /in/9vmhT on line 7
Process exited with code 255.

preferences:
50.19 ms | 406 KiB | 5 Q