Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/02/2012, 20:42
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Uso while en php

mmm te refieres a algo así?

Código PHP:
Ver original
  1. <?php
  2. $a = array("perro", "mono");
  3. $b = array(2, 3, 4, 5, 6);
  4.  
  5. foreach ($a as $animal) {
  6.     echo "$animal<br />";
  7.     foreach ($b as $valor) {
  8.         echo "$valor<br />";
  9.     }
  10. }

con while:

Código PHP:
Ver original
  1. <?php
  2. $a = array("perro", "mono");
  3. $b = array(2, 3, 4, 5, 6);
  4.  
  5. $i = 0;
  6.  
  7. while ($i < count($a)) {
  8.     $j = 0;
  9.     echo "$a[$i]<br />";
  10.     while ($j < count($b)) {
  11.         echo "$b[$j]<br />";
  12.         $j++;
  13.     }
  14.     $i++;
  15. }
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP