- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
array_uintersect_uassoc() function in PHP
The array_uintersect_unassoc() function compares array keys and array values in user-made functions, and returns an array
Syntax
array_uintersect_uassoc(arr1, arr2, arr3, … , compare_func1, compare_func2)
Parameters
arr1 − The first array to compare from.
arr2 − The second array to be compared with.
arr3 − More arrays to compare.
compare_func1 − The comparison function that compares the array keys. It must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
compare_func2 − The comparison function that compares the array values. It must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
Return
The array_uintersect_uassoc() function returns an array containing all the values of the first array that are not present in any of the other parameters.
Example
The following is an example −
<?php function compare_func_key($a, $b) { if ($a === $b) { return 0; } return ($a > $b)? 1:-1; } function compare_func_val($a, $b) { if ($a === $b) { return 0; } return ($a > $b)? 1:-1; } $arr1 = array("a" => "laptop", "b" => "keyboard", "c" => "mouse"); $arr2 = array("a" => "laptop", "b" => "keyboard", "c" => "headphone"); $res = array_uintersect_uassoc($arr1, $arr2, "compare_func_key", "compare_func_val"); print_r($res); ?>
Output
The following is the output −
ArrayArray ( [a] => laptop [b] => keyboard )