English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP array_uintersect_uassoc() Function Usage and Example

PHP Array Function Manual

The array_uintersect_uassoc() function calculates the intersection of arrays with index checking, using separate callback functions to compare data and indices

Syntax

array_uintersect_assoc( $array1, $array2 [, $array3 ..., $func1], $func2 );

Definition and Usage

This function returns an array containing array1of all values, these values appear in all parameters array2、array3Through additional index checks, callback function comparisons, and index comparisons to return the intersection of multiple arrays.

Parameter

Serial NumberParameters and Description
1

array1(Required)

It specifies an array.

2

array2(Required)

It specifies the array to be compared with the first array.

3

array3(Optional)

It specifies the array to be compared with the first array.

4

func1(Required)

The name of the user-defined function used to compare array keys.

5

func2(Required)

The name of the user-defined function used to compare array values.

Online Example

The array_uintersect_uassoc function uses two strcasecmp functions to compare the keys and values of two arrays, calculating the intersection of two arrays

<?php
   $input1 = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red");
   $input2 = array("a"=>"GREEN", "B"=>"brown", "yellow", "red");
   
   print_r(array_uintersect_uassoc($input1, $input2, "strcasecmp", "strcasecmp"));
?>
Test and see‹/›

Output Result:

Array ( [a] => green [b] => brown )

   PHP Array Function Manual