note 114605 deleted from function.array-diff by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 14:50:30 +0000 |
| Subject: | note 114605 deleted from function.array-diff by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212946@lists.php.net to get a copy of this message | ||
Note Submitter: MD dot ABU SAYEM=>sayem at asterisbd dot com
----
//array_diff function compare first array against all of the array and return the elements with
index that are not present in either of the array.
<?php
$array1 = array("a" => "green", "red",
"c"=>"blue", "red","cyan",2,3,"white");
$array2 = array("b" => "green", "yellow", "red");
$array3 = array("b" => "green", "yellow", "white",4);
$array4 = array("b" => "green", "yellow", "blue",2);
$result = array_diff($array1, $array2,$array3,$array4);
echo "<pre>";
print_r($result);
?>
//outputs
Array
(
[3] => cyan
[5] => 3
)