gpt4 book ai didi

php - 从多维数组中提取值并放置在逗号分隔的字符串中

转载 作者:行者123 更新时间:2023-12-02 06:41:15 25 4
gpt4 key购买 nike

<分区>

我有一个看起来像这样的数组

Array
(
[1] => Array
(
[name] => Zeze
[city] => Denver,
[state] => Colorado,
[country] => United States
[user_id] => 1
[cars] => Array
(
[140] => Array
(
[cars_name] => BMW
)

[162] => Array
(
[cars_name] => Mazda
)
)
)

[8] => Array
(
[name] => Lex
[city] => Schwelm,
[state] => North Rhine-Westphalia,
[country] => Germany
[user_id] => 5
[cars] => Array
(
[140] => Array
(
[cars_name] => Mercedes
)

[162] => Array
(
[cars_name] => Audi
)
)
)
)

我需要从 user_id 中提取值并将其放入逗号分隔的字符串中。

对于上面的数组,我想得到:

1,5

我有点困惑如何使用 foreach 循环此数组,然后如何创建字符串?或者有更好的方法吗?

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