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 Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.
---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards