有没有办法在php中的两个数组之间获取公共值?

有没有办法在php中的两个数组之间获取公共值?

问题描述:

是否有可能在 php 中的两个数组之间进行内部连接?例如

Is there a possibility of doing inner join between two arrays in php? for example

如果我有两个数组array1,array2

if i have two arrays array1,array2

输入:

array1[0]['id']=1 , array1[1]['id']=2 , array1[2]['id']=3

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

输出:

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

是否可以使用任何内置函数检索公共值?

is it possible to retrieve common values with any inbuilt functions?

谢谢,巴兰

array_intersect() 函数可能就是您正在寻找的函数 ;-)

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