3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array1 = '[{ "product_name": "Product1", "qty": "1" }, { "product_name": "Product2", "qty": "2" }, { "product_name": "Product3", "qty": "3" }]'; $array2 = '[{ "product_name": "Product4", "qty": "1" }, { "product_name": "Product3", "qty": "1" }, { "product_name": "Product2", "qty": "1" }]'; $arr1 = json_decode($array1, true); $arr2 = json_decode($array2, true); $result = array_merge($arr1,$arr2); var_export($result);
based on 56P4a
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0beta1
array ( 0 => array ( 'product_name' => 'Product1', 'qty' => '1', ), 1 => array ( 'product_name' => 'Product2', 'qty' => '2', ), 2 => array ( 'product_name' => 'Product3', 'qty' => '3', ), 3 => array ( 'product_name' => 'Product4', 'qty' => '1', ), 4 => array ( 'product_name' => 'Product3', 'qty' => '1', ), 5 => array ( 'product_name' => 'Product2', 'qty' => '1', ), )