array_entersect_ukey() function in PHP

WBOY
Release: 2023-09-06 09:38:01
forward
1159 people have browsed it

array_entersect_ukey() function in PHP

array_intersect_ukey() function compares the keys of an array, checks with additional user-defined functions, and returns matching results. This function returns an array containing the entries in the first array that are present in all other arrays.

Syntax

array_intersect_ukey(arr1, arr2, arr3, arr4, …, compare_func)
Copy after login

Parameters

  • arr1 - The array to compare. Required.

  • arr2 - The array to compare. Required.

  • arr3 -You can add more arrays to compare. Optional.

  • arr4 - You can add more arrays to compare. Optional.

  • compare_func - If the first argument is considered <,则此回调函数必须返回一个小于 0 的整数 <、= 或 > , = or > respectively instead of the second.

Return

array_intersect_ukey() function returns an array containing the entries present in the first array in all other arrays.

Example

The following is an example of comparing keys.

Real-time demonstration

<?php
function check($a,$b) {
   if ($a===$b) {
      return 0;
   }
   return ($a>$b)?1:-1;
}
$arr1 = array("a"=>"one","b"=>"two","c"=>"three");
$arr2 = array("a"=>"one","b"=>"two");
$result = array_intersect_ukey($arr1,$arr2,"check");
print_r($result);
?>
Copy after login

Output

Array
(
[a] => one
[b] => two
)
Copy after login

The above is the detailed content of array_entersect_ukey() 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!