3v4l.org

run code in 300+ PHP versions simultaneously
<?php $customers='[ { "id": 1, "name": "sara", "phone": 1100, "mobile": 1111 }, { "id": 2, "name": "ben", "phone": 2200, "mobile": 2222 } ]'; $data = json_decode($customers, true); function findCustomerInArr($array,$customerName){ $customerFound = false; foreach($array as $a){ if(strtolower($a['name']) == strtolower($customerName)){ $customerFound = true; echo $customerName."'s phone is ".$a['phone'].PHP_EOL; echo $customerName."'s mobile is ".$a['mobile'].PHP_EOL; break; } } if(false == $customerFound){ echo "No customer found with this name".PHP_EOL; } } findCustomerInArr($data,'sara'); findCustomerInArr($data,'aliveToDie');
Output for git.master, git.master_jit, rfc.property-hooks
sara's phone is 1100 sara's mobile is 1111 No customer found with this name

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
36.9 ms | 405 KiB | 5 Q