Re: beginner question about while loops

From: Date: Fri, 06 Feb 2004 20:15:11 +0000
Subject: Re: beginner question about while loops
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-177042@lists.php.net to get a copy of this message
"Paul Furman" <paul@edgehill.net> wrote in message news:20040206200812.52972.qmail@pb1.pair.com... > Eric Gorr wrote: [snip] > > while ($file = readdir($fh)){ > if (strstr ($file, '.jpg')){ > $pictures[] = $file; > #print $pictures[]; #Fatal error: Cannot use [] for reading Which element are you trying to print? I'm guessing the current one, so just use: print $file; > } > var_dump ($pictures[]); #Fatal error: Cannot use [] for reading > } > > > > This one works but complains about Undefined variable: pictures NULL > array (but it dumps the contents of $pictures[]: > > while ($file = readdir($fh)){ > if (strstr ($file, '.jpg')){ > $pictures[] = $file; > } > var_dump ($pictures); > }

« previous php.general (#177042) next »