How to use array_diff (ar1, ar2 …) function in php

The array_diff() function compares ar1 against one or more other arrays and returns the values in ar2 that are not present in any of the other arrays.

Example

<?php
$array1 = array("lang" => "php", "java", ".net", "python");
$array2 = array("lang" => "perl", "java", "python");
$result = array_diff($array1, $array2);
print_r($result);
?>

Output of array_diff() function example
Output of example

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top