fork download
  1. <?php
  2. //Creem un array amb 3 valors.
  3. $cars = array("Volvo", "BMW", "Toyota");
  4. //Creem una variable que conta la quantitat de valors
  5. //de la variable $cars i o passa a valor numèric.
  6. $arrlength = count($cars);
  7.  
  8. //Bucle que mostra els cotxes mentre la variable $x sigui
  9. //més petita o igual a la variable $arrlenght.
  10. for($x = 0; $x < $arrlength; $x++) {
  11. echo $cars[$x];
  12. echo "<br />";
  13. }
  14. ?>
Success #stdin #stdout 0.03s 25408KB
stdin
Standard input is empty
stdout
   Volvo<br />BMW<br />Toyota<br />