3v4l.org

run code in 500+ PHP versions simultaneously
<?php $customers='[ { "id": 1, "name": "sara", "phone": 1100, "mobile": 1111 }, { "id": 2, "name": "ben", "phone": 2200, "mobile": 2222 } ]'; foreach(json_decode($customers, true) as $a){ if($a['name'] == 'sara'){ $phone = $a['phone']; $mobile = $a['mobile']; echo "sara's phone is $phone"; echo "sara's mobile is $mobile"; } else{ echo "No customer found with this name"; } }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
sara's phone is 1100sara's mobile is 1111No customer found with this name

preferences:
73.58 ms | 1109 KiB | 4 Q