gpt4 book ai didi

多维数组中的Php字符串比较

转载 作者:搜寻专家 更新时间:2023-10-31 21:53:19 25 4
gpt4 key购买 nike

我有两个多维数组

Array
(
[0] => Array
(
[code] => 2079
[label] => Nike
)

[1] => Array
(
[code] => 1080
[label] => Adidas
)
)

Array
(
[0] => Array
(
[manufacturers_id] => 2753
[manufacturers_name] => Reebok
)

[1] => Array
(
[manufacturers_id] => 2526
[manufacturers_name] => Adidas
)

[2] => Array
(
[manufacturers_id] => 34
[manufacturers_name] => Nike
)

)

我想对数组 1 的键 label 与数组 2 的键 ma​​nufacturer_name 进行字符串匹配。多维数组中的最佳方法是什么?

最佳答案

您可以查看数组。

foreach ($multi_array1 as $value) {  
foreach ($multi_array2 as $value2) {
If ($value[label] === $value2 [manufacturer_name])
{}
}
}

关于多维数组中的Php字符串比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36879793/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com