Answers for "how to compare two multidimensional arrays in php"

PHP
3

compare two arrays and return the difference php

array_merge(array_diff($array1,$array2),array_diff($array2,$array1))
Posted by: Guest on March-11-2021
0

assocititive multi array compare php

NOTE: the diff_array also removes all the duplicate values that match to the values in the second array:



<?php

    $array1 = array("a","b","c","a","a");

    $array2 = array("a");



    $diff = array_diff($array1,$array2);



    // yields: array("b","c") the duplicate "a" values are removed 

?>
Posted by: Guest on July-09-2021

Code answers related to "how to compare two multidimensional arrays in php"

Browse Popular Code Answers by Language