php如何创建foreach循环?
Array
(
[0] => Array
(
[id] =>
[test] => 145198
[defender] => 5590478
[stake] => 107
[game_id] =>
)
[1] => Array
(
[id] =>
[test] => 145198
[defender] => 5590478
[stake] => 107
[game_id] =>
)
如何为其执行 foreach 循环?
到目前为止我已经:
$mresults = $game_set->get_it();
foreach ($mresults as $key => $row)
{ ...dosomething}
但我相信我需要在这个里面做另一件事。
有什么想法吗? 谢谢
Array
(
[0] => Array
(
[id] =>
[test] => 145198
[defender] => 5590478
[stake] => 107
[game_id] =>
)
[1] => Array
(
[id] =>
[test] => 145198
[defender] => 5590478
[stake] => 107
[game_id] =>
)
how to do a foreach loop for it?
so far i have:
$mresults = $game_set->get_it();
foreach ($mresults as $key => $row)
{ ...dosomething}
but i believe i need to do another one inside this one.
any ideas?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你的 foreach 将嵌套数组分配给 $row 变量,并且可以像这样访问:
如果你想再次循环,你可以这样做:
Your foreach assigns the nested array to the $row variable and can be accessed like:
If you wish to loop again, you can do:
不知道你想做什么,但尝试一下:
看看它是如何工作的。
Don't know what you want to do, but try:
To see how it works.
在您的情况下,
$row
将包含该内部数组,因此您可以使用$row['test']
、$row['defender' 输出这些值]
等In your case,
$row
will contain that inner array, so you can output those values using$row['test']
,$row['defender']
, etc.这很可能就是您所需要的:
Most likely this is all you need: