php - Array Diff Confusion -
On trying this code, I am confused why the value yellow was not displayed is.
Can anyone expand it, please?
$ array1 = array ("one" =>, "green", "red", "blue", "red"); $ Array2 = array ("b" => gt; green "," yellow "," red "); $ Result = array_diff ($ array1, $ array2); Print_r ($ result); Multiple events are treated in all ways in the $ array1 . This output will be:
array ([1] => blue)
P> An array that contains all entries from array 1, which are not present in any other array.
According to this, due to the following blue will print it is the only element which is not present in $ array2
It will not print yellow because it checks the elements that are present in $ array1 but are not in $ array2 , no Contrast:
& lt ;? Php $ array1 = array ("a" =>, "green", "red", "blue", "red"); $ Array2 = array ("b" => gt; green "," yellow "," red "); $ Result = array_diff ($ array1, $ array2); Print_r ($ result); ? & Gt; Not available in $ array1 from blue $ array1 , so print it about the elements in the $ array2 Does not care, but $ array1 is not in it, so yellow will not be displayed.
Comments
Post a Comment