3v4l.org

run code in 500+ PHP versions simultaneously
<?php $customer s= '[ { "id": 1, "name": "sara", "phone": 1100, "mobile": 1111 }, { "id": 2, "name": "ben", "phone": 2200, "mobile": 2222 } ]'; $seachFor = 'sara'; $foundCustomer = false; foreach(json_decode($customers, true) as $customer) { if ($customer['name'] == $seachFor) { $foundCustomer = $customer; break; } } if ($foundCustomer) { $phone = $foundCustomer['phone']; $mobile = $foundCustomer['mobile']; echo "sara's phone is $phone\n"; echo "sara's mobile is $mobile"; } else { echo "No customer found with this name"; }
Output for 8.0.1 - 8.0.28, 8.1.0 - 8.1.17, 8.2.0 - 8.2.4, 8.3.5
Parse error: syntax error, unexpected identifier "s" in /in/Ce9T4 on line 3
Process exited with code 255.

preferences:
50.59 ms | 697 KiB | 3 Q