ThinkPHP3.2.3 foreach嵌套循环bug

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ThinkPHP3.2.3 foreach嵌套循环bug相关的知识,希望对你有一定的参考价值。

有两个数组authA和authB

authA如下

 1 Array
 2 (
 3     [0] => Array
 4         (
 5             [auth_id] => 1
 6             [auth_name] => 文章管理
 7             [auth_pid] => 0
 8             [auth_c] => 
 9             [auth_a] => 
10             [auth_level] => 0
11         )
12 
13     [1] => Array
14         (
15             [auth_id] => 4
16             [auth_name] => 系统设置
17             [auth_pid] => 0
18             [auth_c] => 
19             [auth_a] => 
20             [auth_level] => 0
21         )
22 
23 )

authB如下

 1 Array
 2 (
 3     [0] => Array
 4         (
 5             [auth_id] => 2
 6             [auth_name] => 文章列表
 7             [auth_pid] => 1
 8             [auth_c] => Article
 9             [auth_a] => index
10             [auth_level] => 1
11         )
12 
13     [1] => Array
14         (
15             [auth_id] => 3
16             [auth_name] => 添加文章
17             [auth_pid] => 1
18             [auth_c] => Article
19             [auth_a] => add
20             [auth_level] => 1
21         )
22 
23     [2] => Array
24         (
25             [auth_id] => 5
26             [auth_name] => 网站配置
27             [auth_pid] => 4
28             [auth_c] => Config
29             [auth_a] => index
30             [auth_level] => 1
31         )
32 
33     [3] => Array
34         (
35             [auth_id] => 6
36             [auth_name] => 网站备份
37             [auth_pid] => 4
38             [auth_c] => Config
39             [auth_a] => bak
40             [auth_level] => 1
41         )
42 
43 )

正确的循环代码是

技术分享

技术分享

 

若是把vv改成authB,则会出现bug

技术分享

换成其他非authB则不会出现问题

 

以上是关于ThinkPHP3.2.3 foreach嵌套循环bug的主要内容,如果未能解决你的问题,请参考以下文章

thinkphp3.2.3在模板中调用方法

php foreach 嵌套循环大数组很慢?

如何打破嵌套的foreach循环然后转到c#上的父foreach循环

交替循环嵌套的foreach循环

如何在 R 中嵌套 foreach 循环的内循环和外循环之间添加代码

嵌套的 Foreach 循环花费了太多时间