Re: php file writting ?

From: Date: Tue, 18 Mar 2003 20:50:35 +0000
Subject: Re: php file writting ?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-140188@lists.php.net to get a copy of this message
At 3/18/2003 11:46 AM, Steve Keller wrote:
            for($i = 0; $i < count($users); $i++)
            {
                    for($k = 0; $k < count($grouplines);$k++)
                    {
                            $groupline = explode(":", $grouplines[$k]);
                            if($groupline[0] == $users[$i])
                                    continue 2;
                    }
                    $line = $users[$i] . ":x:" . ($user_ids[$i]+1000) .":\n";
                    fwrite($h6, $line);
            }
I may be wrong, but doesnt "continue" jump out of the loop? If so, you're jumping
right over the part of your loop that writes to the file, hence nothing in the file.
I tested this by moving the file writing lines into the conditional just before the "continue 2" line; That way, if there's a match, it writes to the file, *then* skips out of the two loops. It worked just fine. for($i = 0; $i < count($users); $i++) { for($k = 0; $k < count($grouplines);$k++) { $groupline = explode(":", $grouplines[$k]); if($groupline[0] == $users[$i]) { $line = $users[$i] . ":x:" . ($user_ids[$i]+1000) .":\n"; fwrite($h6, $line); continue 2; } } } -- S. Keller UI Engineer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Pkwy. Anchorage, AK 99508 907.770.6200 ext.220 907.336.6205 (fax) Email: skeller@healthtvchannel.org Web: www.healthtvchannel.org

« previous php.general (#140188) next »