In PHP, what is quickest way to turn the following array variables:
$id = [11,12,13];
$code = ['1234','5678','9012'];
$qty = [3,4,5];
$amount = [12.34,23.45,34.56];
Into an array of associative arrays, like the following:
[
['id'=>11,'code'=>'1234','qty'=>3,'amount'=>12.34],
['id'=>12,'code'=>'5678','qty'=>4,'amount'=>23.45],
['id'=>13,'code'=>'9012','qty'=>5,'amount'=>34.56],
]
Currently, I'm doing the following to convert the data.
$max = count($id);
$data = [];
for ($i=0; $i<$max; $i++) {
$data[] = [
'id' => $id[$i],
'code' => $code[$i],
'qty' => $qty[$i],
'amount' => $amount[$i]
];
}
My application does this a lot, and looking if there are ways to decrease processing time.
Currently using PHP version 5.6