PHP:访问数组变量
有人可以帮我访问这个数组吗?我在索引方面遇到了问题。
array(10) {
[0]=>array(2) {
["t"]=>array(1) {
["tag"]=>string(3) "php"
}
[0]=>array(1) {
["NumOccurrances"]=>string(1) "2"
}
}
[1]=>array(2) {
["t"]=>array(1) {
["tag"]=>string(6) "Tomcat"
}
[0]=>array(1) {
["NumOccurrances"]=>string(1) "1"
}
}
}
我想在显示为“PHP x 2”的 foreach 循环中使用它,但索引遇到问题
谢谢
Jonesy
Can someone help me access this array please I'm having trouble with indexes.
array(10) {
[0]=>array(2) {
["t"]=>array(1) {
["tag"]=>string(3) "php"
}
[0]=>array(1) {
["NumOccurrances"]=>string(1) "2"
}
}
[1]=>array(2) {
["t"]=>array(1) {
["tag"]=>string(6) "Tomcat"
}
[0]=>array(1) {
["NumOccurrances"]=>string(1) "1"
}
}
}
I want to use it in a foreach loop displaying like "PHP x 2" but am having trouble with the indexes
Thanks
Jonesy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这个有作用吗?
结构看起来有点奇怪。如果这没有帮助,请提供数组的其余部分。
Does this do?
The structure seems a bit weird. If this does not help, please provide the rest of array.
我不会在这里使用
foreach
循环。foreach
创建数组的副本,因此不如for
循环高效。由于您的第一个维度是数字索引的,我会执行以下操作:我同意 vassilis 的观点,即数组结构是奇怪的。
I wouldn't use a
foreach
loop here.foreach
creates a copy of the array and therefore is not as efficient as afor
loop. Since your first dimension is numerically indexed, I would do the following:I agree with vassilis that the array structure is odd.
类似的东西
会起作用。
something like
Would work.