<ul> Key= "K" mod= "2" > <eq name= "mod" value= "0" > <li>{$k} ... {$arr. ID}---{$arr. User}---{$arr.email}</li> </eq> </volist ></ul>
The values taken are:
- 1...1---lu Fei [email protected]
- 3...3---Crayon [email protected]
- [Email protected]
- 7...65---Be careful [email protected]
- 9...74---aa73f80eb8608a88a135---
- 11...76---_ hehe [email protected]
- [Email protected]
Why is the value taken out like this? According to its own understanding should be $mod = $k% 2; Then for the output of 0, how $k is the cardinality, should not be an even number?
Then look at the source code in the cache:
<ul> <?phpif(Is_array($data)):$k= 0; $__list__=$data; if(Count($__list__) = = 0):Echo""; Else:foreach($__list__ as $key=$arr):$mod= ($k% 2); ++$k; if(($mod) = = "0"):?> <li><?phpEcho($k);? >...<?phpEcho($arr["id"]); ?>---<?phpEcho($arr["User"]); ?>---<?phpEcho($arr["email"]); ? ></li><?phpendif;Endforeach;endif; Else:Echo"";endif;?></ul>
Yes, $k started from 0, and the outside $k was 1.
We do this by defining ourselves as a $i:
<ul> <!--take mod questions-- <php>$i=0;</php> Key= "K" mod= "5" > <eq name= "mod" value= "0" > <li><php>echo$i; </php> {$arr. ID}---{$arr. User}---{$arr.email}</li> </eq> <php >$i++;</php> </volist></ul>
Value:
- 0...1---lu Fei [email protected]
- 2...3---Crayon [email protected]
- [Email protected]
- 6...65---Be careful [email protected]
- 8...74---aa73f80eb8608a88a135---
- 10...76---_ hehe [email protected]
- [Email protected]
The answer is clearly out, it is thinkphp in the MoD $k value changed ....
The problem of mod value in Volist cycle in thinkphp