Answer the question
In order to leave comments, you need to log in
How to compare Two Arrays with condition?
Good day friends. There are two datasets. I get one from a DB, I get the second from other server. Structurally, they are the same.
I need to compare these two arrays, but at the same time, they are the same strings.
Array A contains: name, age, avatar. Array B contains the same. I need to check. If arrayA[name] == arrayB[name], then perform the operation.
Confused about loops, how do I fully compare two arrays, provided that their name field is equal to the same value ?
Thank you.
Answer the question
In order to leave comments, you need to log in
$diff = array_diff_assoc($a, $b);
if (count($diff)) {
// массив $b отличается от массива $a
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question