Re: beginner question about while loops
| From: | Eric Gorr | Date: | Fri, 06 Feb 2004 19:50:37 +0000 |
| Subject: | Re: beginner question about while loops | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177039@lists.php.net to get a copy of this message | ||
At 11:41 AM -0800 2/6/04, Paul Furman wrote:
while ($file = readdir($dh)){
if (strstr ($file, '.jpg')){
$pictures[] = $file;
}
Spotted this problem when staring at your code.
Number of open braces: 2
Number of close braces: 1
You need to close off your while loop.
Should I set up a counter for loops $integer++ or if I'm going through somethingYou can if you like, but it is not necessary in this case.
the while function knows to just go through those and fills in array numbers accordingly?The while function has nothing to do with it. Using the syntex $array[] simply adds an element onto the _end_ of the array and PHP picks the next logical, numerical index.