• PHP Video Tutorials

PHP - Function array_intersect_uassoc()



Syntax

array_intersect_uassoc($array1, $array2 [, $array3 ..., callback $key_compare_func] );

Definition and Usage

It returns an array containing all the values of array1 that are present in all the arguments.

Parameters

Sr.No Parameter & Description
1

array1(Required)

The first array is the array that the others will be compared with.

2

array2(Required)

This is an array to be compared with the first array

3

array3(Optional)

This is an array to be compared with the first array

4

key_compare_func(Required)

User defined call back function.

Return Values

It returns an array containing all the values of array1 that are present in all the arguments.

Example

Try out following example −

<?php
   $input1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
   $input2 = array("a" => "GREEN", "B" => "brown", "yellow", "RED");
   
   $result = array_intersect_uassoc($input1, $input2, "strcasecmp");
   print_r($result);
?> 

This will produce the following result −

Array ( [b] => brown )
php_function_reference.htm
Advertisements