PHP/Data Structure/each

Материал из Web эксперт
Версия от 10:02, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

each() function returns the key-value pair at the current pointer position and moves the pointer to the next element.

   <source lang="html4strict">

//The syntax is: array each (array array) <?

   $spices = array("A", "B", "C", "D", "E");
   reset($spices);
   $a_spice = each($spices);
   print_r($a_spice[1]);
   print_r($a_spice["value"]);

?>

 </source>
   
  


Using each() function in conjunction with list()

   <source lang="html4strict">

<?

   $spices = array("A", "B", "C", "D", "E");
   reset ($spices);
   while ( list ($key, $val) = each ($spices) ) :
        print "$val 
"; endwhile;

?>

 </source>