Pass in two arrays into array_map in PHP

Description

The following code shows how to pass in two arrays into array_map.

Example


/*from www  . j  a  va2  s. c  o m*/
<?php
function myfunction($v1,$v2){
   if ($v1===$v2){
     return "same";
   }
   return "different";
}
$a1=array("Horse","Dog","Cat");
$a2=array("Cow","Dog","Rat");
print_r(array_map("myfunction",$a1,$a2));
?>

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