3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = json_decode(' [ { "Product": "430400", "Delivery": "Delivered", "Size": "24", "UnitPrice": 9.750000 }, { "Product": "430410", "Delivery": "Delivered", "Size": "26", "UnitPrice": 9.750000 } ]',true); function valIsConsistent($items, $key){ if(count($items) == 0){ return false;//hmmm IDK } $prevVal = $items[0][$key]; foreach($items as $item){ if($item[$key] !== $prevVal){ return false; } } return true; } var_dump($items); var_dump(valIsConsistent($items,'Delivery')); var_dump(valIsConsistent($items,'Size'));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> array(4) { ["Product"]=> string(6) "430400" ["Delivery"]=> string(9) "Delivered" ["Size"]=> string(2) "24" ["UnitPrice"]=> float(9.75) } [1]=> array(4) { ["Product"]=> string(6) "430410" ["Delivery"]=> string(9) "Delivered" ["Size"]=> string(2) "26" ["UnitPrice"]=> float(9.75) } } bool(true) bool(false)

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:
66.05 ms | 402 KiB | 8 Q