Php array uintersect assoc
From w3cyberlearnings
Contents |
PHP function array_uintersect_assoc
This function compares two or more arrays with a user-defined functions.
This comparison is based on the first array. When the function returns 0, the array element will be return.
Syntax array_uintersect_assoc
- array1: array input
- array2: array input
- array3: array input
- callback: user-defined function
array_uintersect_assoc (array1, array2, array3, ..,callback);
Example 1
<?php $score_name1 = array(30 => 'John3', 13 => 'Christ', 41 => 'Mark'); $score_name2 = array(31 => 'John', 41 => 'Christ', 41 => 'Mark'); $score = array_uintersect_assoc($score_name1, $score_name2, "strcasecmp"); print_r($score); ?>
Output
Array ( [41] => Mark )
Example 2
<?php $score_name1 = array(30 => 'John3', 13 => 'Christ', 41 => 'Mark'); $score_name2 = array(31 => 'John', 41 => 'Christ', 41 => 'Mark'); function checkscore($k1, $k2) { if($k1 === $k2) { return 0; } else { return 1; } } $score = array_uintersect_assoc($score_name1, $score_name2, "checkscore"); print_r($score); ?>
Output
Array ( [41] => Mark )
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