How to compare two multidimentional array and return parent key in php
Get the solution ↓↓↓for example i have two arrays
$first = array(52=>array(10,24),55=>array(5,25))
$two = array(52=>array(10,24),55=>array(10,25))
in above two arrays how to return parent key if arrays values are not match , expected out put is
array(0=>55)
Answer
Solution:
You needarray_udiff
:
$first = array(52=>array(10,24),55=>array(5,25));
$two = array(52=>array(10,24),55=>array(10,25));
function compare_func($a, $b)
{
if ($a === $b) {
return 0;
}
return ($a > $b)? 1:-1;
}
$diff = array_udiff($first, $two, 'compare_func');
print_r(array_keys($diff));
Array
(
[0] => 55
)
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: mark bundle as not supporting multiuse
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.