Php array uintersect uassoc
From w3cyberlearnings
Contents |
PHP function array_uintersect_uassoc
This function compares two or more arrays with two user-defined functions. The first user-defined function will be used for the keys comparison, and the second function will be used for the values comparison. This comparison is based on the first array. When the function return 0, the array element will be return.
Syntax array_uintersect_uassoc
- array1: array input.
- array2: array input.
- callback1: user-defined function for array keys comparison.
- callback2: user-defined function for array values comparison.
array_uintersect_uassoc(array1, array2, array3,..,callback1, callback2);
Example 1
<?php function func_key($v1, $v2) { if ($v1 === $v2) { return 0; } return 1; } function func_value($v1, $v2) { if ($v1 === $v2) { return 0; } return 1; } $group1 = array( 'Liam' => 'apple', 'Abana' => 'banana', 'Ababuo' => 'bee' ); $group2 = array( 'Liam' => 'apple', 'Abana' => 'Banana', 'Ababuo' => 'bee' ); $rs = array_uintersect_uassoc($group1, $group2, "func_key", "func_value"); print_r($rs); ?>
Output
Array ( [Liam] => apple [Ababuo] => bee )
Related Links
- array_change_key_case
- array_chunk
- array_combine
- array_count_values
- array_diff_assoc
- array_diff_key
- array_diff_uassoc
- array_diff_ukey
- array_diff
- array_fill_keys
- array_fill
- array_filter
- array_flip
- array_intersect_assoc
- array_intersect_key
- array_intersect_uassoc
- array_intersect_ukey
- array_intersect
- array_key_ exists
- array_keys