3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $products = (object)array("barrels"=>array("chemID"=> 1, "catID" => 1),array("chemID"=> 2, "catID" => 1)); $carts = (object)array(array("chemID"=> 1, "catID" => 4),array("chemID"=> 2, "catID" => 4), array("chemID"=> 2, "catID" => 1)); var_dump($products); foreach($products as $key) { foreach($key as $value) { echo $key . ' ' . $value; } }
based on S9ZcZ
Output for 7.2.0
object(stdClass)#1 (2) { ["barrels"]=> array(2) { ["chemID"]=> int(1) ["catID"]=> int(1) } ["0"]=> array(2) { ["chemID"]=> int(2) ["catID"]=> int(1) } } Notice: Array to string conversion in /in/6L2Sq on line 8 Array 1 Notice: Array to string conversion in /in/6L2Sq on line 8 Array 1 Notice: Array to string conversion in /in/6L2Sq on line 8 Array 2 Notice: Array to string conversion in /in/6L2Sq on line 8 Array 1
Output for 5.4.9 - 7.1.10
object(stdClass)#1 (2) { ["barrels"]=> array(2) { ["chemID"]=> int(1) ["catID"]=> int(1) } [0]=> array(2) { ["chemID"]=> int(2) ["catID"]=> int(1) } } Notice: Array to string conversion in /in/6L2Sq on line 8 Array 1 Notice: Array to string conversion in /in/6L2Sq on line 8 Array 1 Notice: Array to string conversion in /in/6L2Sq on line 8 Array 2 Notice: Array to string conversion in /in/6L2Sq on line 8 Array 1
Output for 5.3.19 - 5.3.29
object(stdClass)#1 (2) { ["barrels"]=> array(2) { ["chemID"]=> int(1) ["catID"]=> int(1) } [0]=> array(2) { ["chemID"]=> int(2) ["catID"]=> int(1) } } Array 1Array 1Array 2Array 1