Accessing variables
| From: | Ken N | Date: | Fri, 30 Jun 2000 13:31:46 +0000 |
| Subject: | Accessing variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4076@lists.php.net to get a copy of this message | ||
Hi,
I have a strange question about variables. It seems like I can't
access my variable $i from a do/while that sits nested inside of a while
loop. If you look at the code below you'll see that I am printing line
number twice. What happnes is that The first echo(line) prints that line,
lets say 1234, then the second echo prints it bold just prints the same
line number 1234 seven times. however $i should be incremented every time.
The code is below maybe that'll make more sense.
while(list($line_num, $line) = each($httpd_conf))
{
if(ereg("@lime", $line))
{
$i = ($line_num - 2);
echo("$line_num<BR>");
do {
$line = "#Removed $httpd_conf[$i]";
//echo("#Removed $httpd_conf[$i]<BR>");
echo("$line<BR>");
echo("<B>$line_num</B><BR>");
$i ++;
} while(!ereg("</V", $httpd_conf[$i]));
$i = $i++;
echo("#Removed $httpd_conf[$i]<BR>");
}
fputs($httpd_new, $line);
}
Thanks
Ken N
http://cleveland.lug.net/~rocket/
The answer is simple if you grant that ironies are like submarines;
dangerous only when submerged.