[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 {* simple case *} 2 {foreach array( 1, 2, 3 ) as $i} 3 i={$i} 4 5 {/foreach} 6 ===================================== 7 {* using key_var and break *} 8 {foreach hash( 'k1', 'v1', 'k2', 'v2', 'k3', 'v3' ) as $key => $val} 9 {$key} => {$val} 10 11 {if eq( $val, 'v2' )} 12 {break} 13 {/if} 14 {/foreach} 15 ===================================== 16 {* test delimiter/continue/skip/sequence *} 17 {def $array=array( 'a', 'b', 'c', 'd', 'e', 'f' )} 18 {def $seq=array( 'dark', 'light' )} 19 20 {foreach $array as $i sequence $seq as $color} 21 {delimiter} :: {/delimiter} 22 {if eq( $i, 'c' )} 23 {skip} 24 {elseif eq( $i, 'e' )} 25 {continue} 26 {/if} 27 {$i} 28 {/foreach} 29 30 ===================================== 31 {* test delimiter/continue/skip/sequence, delimiter at bottom *} 32 {foreach $array as $i sequence $seq as $color} 33 {if eq( $i, 'c' )} 34 {skip} 35 {elseif eq( $i, 'e' )} 36 {continue} 37 {/if} 38 {$i} 39 {delimiter} :: {/delimiter} 40 {/foreach} 41 42 ===================================== 43 {* test max/offset *} 44 {foreach $array as $i max 3 offset 1} 45 {$i} 46 47 {/foreach} 48 ===================================== 49 {* test max/offset/reverse *} 50 {foreach $array as $i max 3 offset 1 reverse} 51 {$i} 52 53 {/foreach} 54 55 {* this should produce no errors/warnings *} 56 {foreach array() as $i} 57 {/foreach}
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |