Php array uintersect
From w3cyberlearnings
Contents |
PHP function array_uintersect
This function compares two or more array. It returns an array key and value pairs from the first array that each of its elements existed in other arrays by doing the comparison in the user-defined function.
Syntax array_uintersect
- array1: array input
- array2: array input
- array3: array input
- callback: user-defined function
array_uintersect(array1, array2, array3..,callback);
Example 1
<?php $score1 = array(40, 53, 43, 23); $score2 = array(53, 40, 42, 43); $score3 = array(34, 53, 43, 32); function callback($v1, $v2) { if ($v1 === $v2) { return 0; } else if ($v1 > $v2) { return 1; } else { return -1; } } $score_intersect = array_uintersect($score1, $score2, $score3, "callback"); print_r($score_intersect); ?>
Output
Array ( [1] => 53 [2] => 43 )
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