| 
<?php
$data["name"] = array ("hans", "dennis", "christine", "karl", "horst");
 $data["town"] = array ("Tübingen", "Reutlingen", "Paris", "Toronto", "Göhlen");
 
 // include API:
 include ("phptempt.php");
 
 // include precompiled template:
 $t = new phptempt ("three_color.inc");
 
 for ($i=0; $i<sizeof($data["name"]); $i++) {
 
 $t->begin ("aBlock");
 if ($i % 3 == 0)
 $t->begin ("nested1");
 else if ($i % 3 == 1)
 $t->begin ("nested2");
 else
 $t->begin ("nested3");
 
 // add data to one of the three blocks in turn:
 $t->addVal ("NAME", $data["name"][$i]);
 $t->addVal ("TOWN", $data["town"][$i]);
 
 if ($i % 3 == 0)
 $t->end ("nested1");
 else if ($i % 3 == 1)
 $t->end ("nested2");
 else
 $t->end ("nested3");
 $t->end ("aBlock");
 }
 
 // output template:
 $t->out ();
 ?>
 |