3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr= array ( 'supplier_id' => 1, 'filter_name' => array ( 0 => 'product 1', 1 => 'Product 2', 2 => 'Product 3' ), 'quantity' => array ( 0 => 3, 1 => 10, 2 => 2 ), 'unit' => array ( 0 => 'pkts', 1 => 'ltrs', 2 => 'pkts' ), 'price' => Array ( 0 => 11, 1 => 100, 2 => 10 ), 'gross_amount' => Array ( 0 => 33, 1 => 1000, 2 => 20 ), 'vat' => array ( 0 => 0, 1 => 0, 2 => 0 ), 'net_amount' => array ( 0 => 33, 1 => 1000, 2 => 20 ), ); //echo "<pre>"; print_r($arr); $i = 0; $newArray = array(); do{ foreach($arr as $key=>$val){ if($key == 'supplier_id'){ $newArray[$key] = $val; }else{ $newArray[$i][$key] = $val[$i]; } } $i++; }while($i<3); echo "<pre>"; print_r($newArray);

preferences:
24.23 ms | 404 KiB | 5 Q