- array_map: documentation ( source)
- array_combine: documentation ( source)
- print_r: documentation ( source)
- array_keys: documentation ( source)
<?php
$keys = array('phrase', 'fruit');
$ar = ['a'=>'apple', 'b'=>'banana', 'c'=>'pear'];
$new_ar = array_map(function ($v, $k) use ($keys) {
return array_combine($keys, array($k, $v));
}, $ar, array_keys($ar));
print_r($new_ar);