Re: Accessing variables
| From: | Hans Lellelid | Date: | Fri, 30 Jun 2000 17:47:44 +0000 |
| Subject: | Re: Accessing variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4077@lists.php.net to get a copy of this message | ||
> $i ++;
> } while(!ereg("</V", $httpd_conf[$i]));
> $i = $i++;
> echo("#Removed $httpd_conf[$i]<BR>");
It seems that on the 3rd line of this block, you should put "$i = ++$i;".
The assigment $i=$i++ is going to prevent the value of $i from incrementing
(since the increment is done *after* the assign).
HTH,
Hans Lellelid
----- Original Message -----
From: "Ken N" <kenn@pcintelligent.com>
To: <php-general@lists.php.net>
Sent: Friday, June 30, 2000 9:31 AM
Subject: [PHP] Accessing variables
> 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]";
> file://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.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net