In Arrays lecture, I described about types of Array.
Types of Array in PHP
- Indexed arrays - Arrays with numeric index
- Associative arrays - Arrays with named keys
- Multidimensional arrays - Arrays containing one or more arrays
Here you will come to know that how to compare PHP arrays and how to fetch same value. Sometimes you have to get user detail and compare their attributes.
Just like- Reviews
- Top Contributors
- Levels
- Addresses
- Cast
- Religion
- Country
- and more
The most important thing you need to understand
array_intersectConcept. Array_Intersect is used to fetch same values between two arrays.
Here you will come to know, How to check arrays values for duplication?
Compare Arrays Code:
(Indexed Arrays, Associative Arrays, Multidimensional arrays)
<?php
$array1 = array('Samee', 'Ullah', 'Feroz');
$array2 = array('SEO', 'SMO', 'PPC', 'Samee');
$campare = array_intersect($array1, $array2);
print_r($campare);
echo "<br />";
// => Output would be <=
// Array ( [0] => Samee )
$array1 = array('author' => 'Samee', 'Ullah', 'Feroz');
$array2 = array('SEO', 'SMO', 'PPC', 'worker' => 'Samee');
$campare = array_intersect($array1, $array2);
print_r($campare);
echo "<br />";
// => Output would be <=
// Array ( [author] => Samee )
$array1 = array('Samee', 'Ullah', array('Mohammad', 'Feroz', 'Din'));
$values = array_values($array1);
$array2 = array('SEO', 'SMO', 'PPC', 'Samee', 'Feroz');
foreach($values as $array)
{
$multiarray = array_intersect($array, $array2);
}
print_r($multiarray);
// => Output would be <=
// Array ( [1] => Feroz )
?>
Most Wanted Terms:
- php compare arrays
- php array compare
- php compare array
- php compare two arrays
- compare arrays php
- php compare array values
- php compare 2 arrays
- compare two arrays php
- array compare php
- php array of arrays

Post a Comment
Give your reviews about this blog. Leave your comments. What do you think about this post?
Comments Guidelines:
1) I love to read comments, but please avoid spam.
2) Like this blog, share your insights, and spread the word.
3) You can use basic HTML/xHTML tags.
4) All comments are DoFollow—please use the section professionally.
5) Kindly mention your name or brand below your comment.
6) Constructive suggestions for improvement are always welcome.
Thanks for visiting Samee Articles.
========================================
Best Regards,
Samee U. Feroz