- var_export: documentation ( source)
- intdiv: documentation ( source)
- key: documentation ( source)
<?php
$array = [
['term_title' => 'black'],
['color_quantity' => 2],
['color_price' => 22],
['term_title' => 'blue'],
['color_quantity' => 3],
['color_price' => 33],
];
foreach ($array as $index => $subarray) {
$key = key($subarray);
$result[intdiv($index, 3)][$key] = $subarray[$key];
}
var_export($result);