3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = array(); class Products { public $chemID; public $catID; } $prod1 = new Products; $prod1->chemID=1; $prod1->catID=1; array_push($products,$prod1); for($i = 1; $i < 5; $i++) { ${'prod'.$i} = new Products; ${'prod'.$i}->chemID = $i; ${'prod'.$i}->catID = $i; array_push($products,${'prod'.$i}); } $carts = (object)array(array("chemID"=> 1, "catID" => 4),array("chemID"=> 2, "catID" => 4), array("chemID"=> 1, "catID" => 1)); $cnt = 0; foreach($products as $pkey=>$pobj) { foreach($carts as $ckey=>$carray) { if(isset($carray['chemID']) && isset($pobj['chemID']) && $carray['chemID']==$pobj['chemID']) { if(isset($carray['catID']) && isset($pobj['catID']) && $carray['catID']==$pobj['catID']) { $cnt++; } } } } echo $cnt;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Cannot use object of type Products as array in /in/dpmuh:22 Stack trace: #0 {main} thrown in /in/dpmuh on line 22
Process exited with code 255.

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:
58.49 ms | 401 KiB | 8 Q