PHP Classes

File: examples/templates/foreach.html

Recommend this page to a friend!
  Classes of tokkara  >  Simphple  >  examples/templates/foreach.html  >  Download  
File: examples/templates/foreach.html
Role: Auxiliary data
Content type: text/plain
Description: Documentation
Class: Simphple
Process templates compiling into PHP code
Author: By
Last change: simphple version 1.1.0
Date: 9 years ago
Size: 2,438 bytes


Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Foreach structure example</title>
	<h1>Simple array in foreach</h1>
		<!-- FOREACH c=$colors -->
		<!-- ENDFOREACH -->

	<h1>Multilevel array in foreach</h1>
		<!-- FOREACH n_ary=array(array(1,2), array(3,4), array(5,6)) -->
		<li><b>Position {$n_ary._CUR_+1:}</b>
				<!-- FOREACH number=$n_ary._VAL_ -->
				<!-- ENDFOREACH -->
		<!-- ENDFOREACH -->

	<h1>Array with keys in foreach</h1>
	<!-- FOREACH country = $countries -->
		<li><b>Name: </b>$</li>
		<li><b>Language: </b>$country.language</li>
		<li><b>Continent: </b>$country.continent</li>
				<!-- FOREACH city = $country.cities -->
				<!-- ENDFOREACH -->
	<br />
	<!-- ENDFOREACH -->

	<h1>Special variables for foreach structure</h1>
	<table border="1" cellpadding="3" style="text-align: left;">
		<tr style="font-size: 14pt">
			<th>Element <span style="font-size: 11pt;">(&#36;n_ary._VAL_)</span></th>
			<th>Current <span style="font-size: 11pt;">(&#36;n_ary._CUR_)</span></th>
			<th>Max <span style="font-size: 11pt;">(&#36;n_ary._MAX_)</span></th>
			<th>First <span style="font-size: 11pt;">(&#36;n_ary._FIRST_)</span></th>
			<th>Last <span style="font-size: 11pt;">(&#36;n_ary._LAST_)</span></th>
			<th>Even <span style="font-size: 11pt;">(&#36;n_ary._EVEN_)</span></th>
		<!-- FOREACH n_ary=array('a', 'e', 'i', 'o', 'u') -->
				<!-- IF $n_ary._FIRST_ -->true<!-- ELSE -->false<!-- ENDIF -->
				<!-- IF $n_ary._LAST_ -->true<!-- ELSE -->false<!-- ENDIF -->
				<!-- IF $n_ary._EVEN_ -->true<!-- ELSE -->false<!-- ENDIF -->
		<!-- ENDFOREACH -->
	<h1>Continue structure in foreach bucle</h1>
	<!-- FOREACH n=$number -->
			<!-- IF $n._VAL_%3==0 -->
				$n._VAL_ is a multiple of 3.
				<!-- CONTINUE -->
			<!-- ENDIF -->
			$n._VAL_ isn't a multiple of 3.
	<!-- ENDFOREACH -->
For more information send a message to info at phpclasses dot org.