Syntax
| array array_diff ( array $array1, array $array2 [, array $array3 ...] ); |
Definition and Usage
Compares array1 against array2 and returns the difference.
Paramters
| Parameter | Description |
|---|---|
| array1 | Required. The first array is the array that the others will be compared with. |
| array2 | Required. An array to be compared with the first array |
| array3 | Optional. An array to be compared with the first array |
Return Values
Returns an array containing the differennces.
Example
Try out following example:
<?php
$input_array1 = array("orange", "banana", "apple");
$input_array2 = array("orange", "mango", "apple");
print_r(array_diff($input_array1, $input_array2));
?>
|
This will produce following result:
Array ( [1] => banana ) |
No comments:
Post a Comment