array_intersect_assoc() function in PHP

PHPz
Release: 2023-08-19 15:42:01
forward
1587 people have browsed it

array_intersect_assoc() function in PHP

The array_intersect_assoc() function compares array values, and returns the matches.

grammar

array_intersect_assoc(arr1, arr2, arr3,  arr4, …)
Copy after login

Parameters

  • arr1 − Array to compare from. Required.

  • arr2 − Array to compare against. Required.

  • arr3 −You can add more arrays for comparison. Optional.

  • arr4 − You can add more arrays for comparison. Optional.

return

The array_intersect_assoc() function returns an array containing all of the values ​​in the first array whose values ​​exist in all of the parameters.

The Chinese translation of

Example

is:

Example

Real-time demonstration

<?php
   $arr1 = array("p"=>"headphone","q"=>"earpod","r"=>"charger");
   $arr2 = array("p"=>"headphone","q"=>"earpod");
   $res = array_intersect_assoc($arr1,$arr2);
   print_r($res);
?>
Copy after login

Output

Array 
(
   [p] => headphone
   [q] => earpod
)
Copy after login

The above is the detailed content of array_intersect_assoc() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!