Is there a way to get common values โ€‹โ€‹between two arrays in php?

Is there any way to make an inner join between two arrays in php? eg

If I have two arrays array1, array2

Entrance:

array1[0]['id']=1 , array1[1]['id']=2 , array1[2]['id']=3 array2[0]['id']=3 , array2[1]['id']=4 , array2[2]['id']=5 

Output:

 array2[0]['id']=3; 

Is it possible to get common values โ€‹โ€‹with any built-in functions?

Thanks Balan

+4
source share
2 answers

The array_intersect() function may be the one you are looking for; -)

+8
source

I could not understand exactly what you needed.

If I guess, I think you need the intersection of two arrays ..

array_intersect can do this ...

If this is not what you need, then please update your question with the exact entry and expected output.

0
source

Source: https://habr.com/ru/post/1346219/


All Articles