Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function array_intersect_uassoc()


previous

Advertisements

Syntax

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

Definition and Usage

Returns an array containing all the values of array1 that are present in all the arguments. Note that the keys are used in the comparison unlike in array_intersect().

Paramters

ParameterDescription
array1Required. The first array is the array that the others will be compared with.
array2Required. An array to be compared with the first array
array3Optional. An array to be compared with the first array
key_compare_funcRequired. User defined call back function.

Return Values

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

Example

Try out following example:

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

This will produce following result:

Array ( [b] => brown )

previous Printer Friendly

Advertisements


  

Advertisements