Tworzenie stron WWW to podstawa pracy webmastera. Dlatego każdy webmaster ma swój Poradnik Webmastera, z którego korzysta gdy potrzebuje wiedzy o języku HTML, CSS albo szuka czegoś w kursie JavaScript. Dzięki tak potężniej dawce wiedzy może on tworzyć profesjonalnie wyglądające strony WWW.

Regały magazynowe - Kredyt gotówkowy - Opisy na Gadu Gadu - zakłady sportowe - Kostkarka do lodu - pozycjonowanie stron wrocław - prezent pod choinke - erotyczna bielizna - kubki z nadrukiem - server lamp - hotel konferencje - wymiana linków - Oryginalne perfumy - Drugi filar - Grille
Podręcznik PEAR
PoprzedniNastępny

{foreach:variable,key,value}

{foreach:variable,key,value} -- creates a PHP foreach loop

Synopsis

Usage ({foreach:variable,key,value}, {foreach:variable,value})

Opis

creates a foreach loop, needs an {end:} tag. note that the engine will add the variable to the scope, so they will not be prefixed with $t-> when used inside the loop.

Parametr

  • string variable - relates to $object->variable

  • string key - creates a variable 'key' in the current scope.

  • string value - optionally creates a variable 'value' in the current scope. (as in $key=>$value)

Przykład

Przykład 43-1. Setting variables for foreach

$this->a = array(
  "dog" => "cat",
  "fire" => "water"
);
$this->b = array('a','b','c');

$template->outputObject($this);

Przykład 43-2. Foreach in template

{foreach:a,k,v}
  k is {k}, and v is {v}
{end:}
{foreach:b,v}
  v is {v}
{end:}

Przykład 43-3. Compiled template

<?php if (is_array($t->a)) foreach($t->a as $k => $v) { ?>
  k is <?php echo htmlspecialchars($k); ?>, and v is <?php echo htmlspecialchars($v); ?>
<?php } ?>
<?php if (is_array($t->a)) foreach($t->b as $v) { ?>
  v is <?php echo htmlspecialchars($v); ?>
<?php } ?>

Przykład 43-4. example output

k is dog, v is cat
k is fire, v is water
v is a
v is b
v is c

PoprzedniSpis treściNastępny
{method(arguments,#quoted arguments#)}Początek rozdziału{if:variable}

Copyright © 2007 Office. Designed by Free CSS Templates.