Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/07/2011, 21:27
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Foreach y funcion count - Error

El problema es que cuando haces el foreach() si la variable esta vacia, no va a entrar por el foreach, tendrías que hacer algo así:
Código PHP:
Ver original
  1. function foo($arr) {
  2.         if (count($arr) == 0) {
  3.                return false;
  4.         }
  5.  
  6.         foreach ($arr as $key => $value) {
  7.  
  8.         }
  9. }

Saludos.