Using the canonical PHPdoc example, this code:
<?php
function cube($n)
{
return($n * $n * $n);
}
$a = array( 3, 4, 5);
$b = array_map("cube", $a);
print_r($b);
?>
outputs
Array
(
[0] => 27
[1] => 64
[2] => 125
)
But what I really want it to output is something along these lines: Array
(
[3] => 27
[4] => 64
[5] => 125
)
That is, I want the array_map to use the same keys as in the original array. Is there any way to do that? Thanks!