How to learn PHParray_intersect (). Learn how to define and use PHParray_intersect () the array_intersect () function returns an intersection array of two or more arrays. The result array contains all the results in the compared array. It also shows how to learn PHP array_intersect ()
Definition and usage
The array_intersect () function returns the intersection array of two or more arrays.
The result array contains all values in the compared array and all other parameter arrays. The key name remains unchanged.
Note: only values are used for comparison.
Syntax
Array_intersect (array1, array2, array3 ...)
Parameters
Description
Array1 is required. The first array to be compared with other arrays.
Array2 is required. The array to be compared with the first array.
Array3 is optional. The array to be compared with the first array. There can be multiple.
Example
"Cat", 1 => "Dog", 2 => "Horse"); $ a2 = array (3 => "Horse", 4 => "Dog ", 5 => "Fish"); print_r (array_intersect ($ a1, $ a2);?>
Output:
Array ([1] => Dog [2] => Horse)
Array_intersect () definition and usage the array_intersect () function returns an intersection array of two or more arrays. The result array contains all the results in the compared array...