php Map函数的用法

function myfunction($v){
  if ($v==="Dog"){
     return "Fido";
  }
  return $v;
}

$a=array("Horse","Dog","Cat");
print_r(array_map("myfunction",$a));

将数组中值的所有字母改为大写

function myfunction($v){
  $v=strtoupper($v);
  return $v;
}

$a=array("Animal" => "horse", "Type" => "mammal");
print_r(array_map("myfunction",$a));