vlibTemplate

vLib Logo

4.3. Simple LOOP
PHP script
   require_once 'vlib/vlibTemplate.php';

   $tmpl = new vlibTemplate('tmpl/loop.htm');

   $loop = array(
     0 => array('u_id' => 1, 'u_name' => 'Claus'),
     1 => array('u_id' => 2, 'u_name' => 'Kelvin'),
     2 => array('u_id' => 3, 'u_name' => 'Skrol'),
     3 => array('u_id' => 4, 'u_name' => 'Micheal')
   );

   $tmpl->setloop('loop', $loop);

   $tmpl->pparse();
Template
   <h1>vlibTemplate LOOP is displayed using <p></h1>

   <tmpl_loop name='loop'>
      <p>User: {tmpl_var name='u_id'} - {tmpl_var name='u_name'}</p>
   </tmpl_loop>