-
- 20 PHP Programs
- Sum of Digits
- Even Odd
- Prime Number
- Table of Number
- Factorial
- Armstrong Number
- Palindrome Number
- Fibonacci Series
- Reverse Number
- Reverse String
- Swapping Two Numbers
- Adding Two Numbers
- Subtracting Two Numbers
- Area of a Triangle
- Area of Rectangle
- Leap Year
- Alphabet Triangle Method
- Alphabet Triangle
- Number Triangle
- Star Triangle
-
- PHP Array
- PHP Indexed Array
- PHP Associative Array
- Multidimensional Array
- PHP Array Functions
- PHP array_arsort() Function
- PHP Array asort() Function
- PHP Array changekeycase() Function
- PHP Array Chunk() Function
- PHP Array column() Function
- PHP Array combine() Function
- PHP Array compact() Function
- PHP Array count() Function
- PHP Array count_values() Function
- PHP Array current() Function
- PHP array_diff_assoc() Function
- PHP array_diff() Function
- PHP array_diff_key() Function
- PHP array_diff_uassoc() Function
- PHP array_diff_ukey() Function
- PHP array each() Function
- PHP array end() Function
- PHP array extract() Function
- PHP array_fill() Function
- PHP array_fill_keys() Function
- PHP array_filter() Function
- PHP array flip() Function
- PHP in_array() Function
- PHP array_intersect_assoc() Function
- PHP array_intersect() Function
- PHP array_intersect_key() Function
- PHP array_intersect_uassoc() Function
- PHP array_intersect_ukey() Function
- PHP array_key_exists() Function
- PHP array_key_first() Function
- PHP array_key() Function
PHP array_intersect_ukey() Function
The array_intersect_ukey() function compares the keys of two or more arrays using a user-defined callback function and returns an array with keys that are present in all arrays.
Key Features of array_intersect_ukey()
- Compares keys using a user-defined callback function.
- Returns an array with matching keys from all arrays.
- Values are not compared, only keys are considered.
Syntax of array_intersect_ukey()
Syntax
array array_intersect_ukey(array $array1, array $array2, callable $callback);
Example Using array_intersect_ukey()
The following example demonstrates how array_intersect_ukey()
works with a user-defined callback function:
Example
$array1 = ["a" => "PHP", "b" => "JavaScript", "c" => "Python"];
$array2 = ["a" => "Ruby", "c" => "Java", "d" => "C++"];
$callback = function($key1, $key2) {
return strcmp($key1, $key2);
};
$result = array_intersect_ukey($array1, $array2, $callback);
print_r($result);
Output
Array ( [a] => PHP [c] => Python )
← Previous Topic
array_intersect_uassoc() Function
PHP array_key_exists() Function
Next Topic →