$input = array(
"drum" => 23,
"bucket" => 26,
"can" => 10,
"skid" => 3,
"gaylord" => 4
);
$output = array_map(fn($count, $name) => ["name" => $name, "count" => $count], $input, array_keys($input));
print_r($output);
You can achieve this transformation in PHP using array_map()
.