gpt4 book ai didi

php - 从数组中拉出数组

转载 作者:行者123 更新时间:2023-12-04 03:17:07 25 4
gpt4 key购买 nike

我有下面的数组,但我似乎不知道如何从数组 Team_1 中提取信息并回显其中的 0 - 5 值。

 array (size=3)
'Team_1' =>
array (size=5)
0 => string '1199' (length=4)
1 => string '1182' (length=4)
2 => string '1105' (length=4)
3 => string '1212' (length=4)
4 => string '891' (length=3)
'Team_2' =>
array (size=5)
0 => string '' (length=0)
1 => string '' (length=0)
2 => string '' (length=0)
3 => string '' (length=0)
4 => string '' (length=0)
'Team_3' =>
array (size=5)
0 => string '' (length=0)
1 => string '' (length=0)
2 => string '' (length=0)
3 => string '' (length=0)
4 => string '' (length=0)

最佳答案

key 是 Team_1,因此您可以直接引用它并执行 foreach 循环来执行回显(您可以添加任何要回显的 html 以格式化值)。

foreach ($arr['Team_1'] as $val) {
echo $val.'<br>';
}

如果您的目的是循环遍历所有团队并回显值

foreach ($teams as $team => $vals) {
echo $team;
foreach ($vals as $val) {
echo $val;
}
}

关于php - 从数组中拉出数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33764920/

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