PHP array_diff() function returns an array consisting only of those values present in the first input array and not present in any other arrays.
Syntax: array_diff(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.
Tip : The first array can compare with single array or more arrays.
Note : Compare only values of the array.
Example:
Syntax: array_diff(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.
Tip : The first array can compare with single array or more arrays.
Note : Compare only values of the array.
Example:
<?php
$daysarr1 = array(0=>"Sunday",1=>"Monday",2=>"Tuesday",3=>"Wednesday");
$daysarr2 = array(4=>"Monday",5=>"Tuesday",6=>"Friday");
print_r( array_diff($daysarr1,$daysarr2) );
?>
Output:
Array (
[0] => Sunday
[3] => Wednesday
)
0 comments:
Post a Comment