3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [ 'product_template_id' => [ '0' => '1', '1' => '2' ], 'amount' => [ '0' => '50', '1' => '100' ] ]; $arr = []; for ($x = 0; $x <= count($array['amount']); $x ++) { $arr[$x] = [ 'product_template_id' => $array['product_template_id'][$x], 'amount' => $array['amount'][$x], ]; } var_dump($arr);
based on 0Chqs
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
Notice: Undefined offset: 2 in /in/cSs08 on line 18 Notice: Undefined offset: 2 in /in/cSs08 on line 19 array(3) { [0]=> array(2) { ["product_template_id"]=> string(1) "1" ["amount"]=> string(2) "50" } [1]=> array(2) { ["product_template_id"]=> string(1) "2" ["amount"]=> string(3) "100" } [2]=> array(2) { ["product_template_id"]=> NULL ["amount"]=> NULL } }
Output for hhvm-3.12.14 - 3.17.3
Notice: Undefined index: 2 in /in/cSs08 on line 18 Notice: Undefined index: 2 in /in/cSs08 on line 19 array(3) { [0]=> array(2) { ["product_template_id"]=> string(1) "1" ["amount"]=> string(2) "50" } [1]=> array(2) { ["product_template_id"]=> string(1) "2" ["amount"]=> string(3) "100" } [2]=> array(2) { ["product_template_id"]=> NULL ["amount"]=> NULL } }