检查 array2 中 array1 的值
在 php 中有以下两个不同的数组:
Array1
(
[0] => Array
(
[id] => 1
[name] => William
)
[1] => Array
(
[id] => 2
[name] => Bob
)
[2] => Array
(
[id] => 3
[name] => Michael
)
)
Array2
(
[0] => Array
(
[id] => 11128
[name] => John
)
[1] => Array
(
[id] => 11127
[name] => Adam
)
[2] => Array
(
[id] => 11126
[name] => Andrew
)
[3] => Array
(
[id] => 11125
[name] => William
)
[4] => Array
(
[id] => 11124
[name] => Bob
)
)
我能以某种方式找到匹配的 name
吗,这样输出将如下所示:
Array1 (1, id:2) matches Array2 (4, id:11124) with name: Bob
Array1 (0, id:1) matches Array2 (3, id:11125) with name: William
如果不清楚,抱歉
Having the following two different arrays in php:
Array1
(
[0] => Array
(
[id] => 1
[name] => William
)
[1] => Array
(
[id] => 2
[name] => Bob
)
[2] => Array
(
[id] => 3
[name] => Michael
)
)
Array2
(
[0] => Array
(
[id] => 11128
[name] => John
)
[1] => Array
(
[id] => 11127
[name] => Adam
)
[2] => Array
(
[id] => 11126
[name] => Andrew
)
[3] => Array
(
[id] => 11125
[name] => William
)
[4] => Array
(
[id] => 11124
[name] => Bob
)
)
Can I somehow find matching name
s so the output will be like:
Array1 (1, id:2) matches Array2 (4, id:11124) with name: Bob
Array1 (0, id:1) matches Array2 (3, id:11125) with name: William
sorry if it's unclear
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您始终可以尝试一个简单的 foreach 循环:
You can always try a simple foreach loop: