compare two array values in PHP
In this post we will give you information about compare two array values in PHP. Hear we will give you detail about compare two array values in PHPAnd how to use it also give you demo for it if it is necessary.
Use the PHP array_diff() function
You can use the PHP array_diff() function to compare an array against one or more other arrays.
The array_diff() function returns the values in the first array that are not present in any of the other arrays. Let’s try out an example to understand how it actually works:
<?php $array1 = array("a" => "sky", "star", "moon", "cloud", "moon"); $array2 = array("b" => "sky", "sun", "moon"); // Comparing the values $result = array_diff($array1, $array2); print_r($result); ?>
Hope this and post will helped you for implement compare two array values in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs