Answers for "compare two arrays and return the difference php"

PHP
4

php find differences between two arrays

<?php
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);

print_r($result);
?>

Array
(
    [1] => blue
)
Posted by: Guest on May-07-2020
1

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

Code answers related to "compare two arrays and return the difference php"

Browse Popular Code Answers by Language