- var_dump: documentation ( source)
- explode: documentation ( source)
<?php
function array_map_key(Callable $callback, $array) {
$return = array();
foreach ($array as $key => $value) {
list($k,$v) = $callback($key, $value);
$return[$k] = $v;
}
return $return;
}
function my_call_back($key, $value) {
return array($value, strlen($value));
}
$array = explode(" ", "PHP stands for PHP hypertext preprocessor");
$array = array_map_key('my_call_back', $array);
var_dump($array);