0
How to go through 2 distinct arrays to verify which values are equal and after the check print only the equal values of both arrays?
The arrays' structures are in the following form below, I tried to traverse using Function in_array
but it doesn’t work, someone can help?
Array 1
Array
(
[0] => Array
(
[id] => 1899
[bola1] => 1
[bola2] => 3
[bola3] => 5
[bola4] => 6
[bola5] => 9
[bola6] => 10
[bola7] => 11
[bola8] => 14
[bola9] => 15
[bola10] => 16
[bola11] => 17
[bola12] => 18
[bola13] => 19
[bola14] => 20
[bola15] => 23
)
)
Array 2
Array
(
[0] => Array
(
[id] => 1
[bola1] => 1
[bola2] => 2
[bola3] => 3
[bola4] => 4
[bola5] => 6
[bola6] => 7
[bola7] => 8
[bola8] => 10
[bola9] => 11
[bola10] => 13
[bola11] => 14
[bola12] => 18
[bola13] => 20
[bola14] => 21
[bola15] => 24
)
)
Does the key and value have to be equal? Only the value? Only the key?
– Benilson
Only the value, for example: the key value [ball1] of Array 1 is 1, the key value [ball1] of Array 2 is 1 so they are equal, prints 1. Already the key value [ball2] of Array 1 is 3, the key value [ball2] of Array 2 is 2, so they are not equal, captured the idea?
– Jorgito da Silva Paiva
See if the array_intersect serves https://www.php.net/manual/en/function.array-intersect.php.
– Benilson
It didn’t work with this array_intersect function
– Jorgito da Silva Paiva