- array_reduce: documentation ( source)
- var_export: documentation ( source)
- array_keys: documentation ( source)
<?php
$arr = [
'4X2' => 86,
'4X3' => 9,
'4X4' => 5,
'6X2' => 14,
'6X4' => 1
];
var_export(
array_reduce(
array_keys($arr),
fn($result, $k) => $result
+ [
$k => [
'title' => $k,
'search' => "&vconfiguration[]=$k",
'count' => $arr[$k]
]
],
[]
)
);