Change all letters of the array values to uppercase with array_map in PHP

Description

The following code shows how to change all letters of the array values to uppercase with array_map.

Example


/*w  ww .j a v a  2s  .  c o m*/
<?php
function myfunction($v) {
   $v=strtoupper($v);
   return $v;
}

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

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone