Home >> PHP >> array_intersect_assoc() function in PHP

array_intersect_assoc() function in PHP

The array_intersect_assoc() function used for compares the keys and values of two or more arrays, and returns the common elements.

Syntax

array_intersect_assoc(array1,array2,array3...);

Example

$array1 = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$array2 = array("a"=>"red","b"=>"green","c"=>"blue");

print_r(array_intersect_assoc($array1,$array2));

Output

Array ( [a] => red [b] => green [c] => blue )

Post Your Comment

Next Questions
array_intersect_key() function
array_intersect_uassoc() function
array_intersect_ukey() function
array_key_exits() function
array_keys() function
array_map() function
array_merge() function
array_merge_recursive() function
array_multisort() function
array_pad() function
array_pop() function
array_product() function
array_push() function
array_rand() function
array_reduce() function
array_reverse() function
array_search() function
array_shift() function
array_slice() function
array_splice() function
array_sum() function
array_udiff() function
array_udiff_assoc() function
array_udiff_uassoc() function
array_uintersect() function

Copyright ©2022 coderraj.com. All Rights Reserved.