array_intersect() function generates an array comparing only of those values available in the first input array that also available in each of the other input arrays.
array2 : Required. An array to be compared with the first array.
array3 : Optional. An array to be compared with the first array.
Syntax: array_intersect(array1,array2,array3...)
Parameters Description:
array1 : Required. The first array will be compared with other arrays.array2 : Required. An array to be compared with the first array.
array3 : Optional. An array to be compared with the first array.
Example:
<?php
$daysarr1 = array(0=>"Sunday",1=>"Monday",2=>"Tuesday");
$daysarr2 = array(3=>"Tuesday",4=>"Monday",5=>"Thursday");
print_r( array_intersect($daysarr1,$daysarr2) );
?>
O/P:
Array (
[1] => Monday
[2] => Tuesday
)
0 comments:
Post a Comment