Re: Accessing variables
| From: | Ken N | Date: | Fri, 30 Jun 2000 14:03:04 +0000 |
| Subject: | Re: Accessing variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4081@lists.php.net to get a copy of this message | ||
Hmm, That didn't help, I really don't understand what it's problem is. If
you desk check the code and talk it out. it reads like this, (I thiink)
*** lets say we mathced on line 10
while(we list the httpd.conf file line by line)
{
if(we match @lime in the cuurrent line as we go through)
{
Then set $i to line number minus 2 //so it's 8B
do {
set $line = to htttpd.cong line 8 adding removed in front of it
add one to line which is now 9
} do this untill we finr this string "</V"
add one to line to we can comment out the closing tag
See what I mean? Which is why I can't understand why line doens't seem to
be incrementing.
Thanks
Ken N
http://cleveland.lug.net/~rocket/
The answer is simple if you grant that ironies are like submarines;
dangerous only when submerged.
On Fri, 30 Jun 2000, Hans Lellelid wrote:
> > $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
>
>
> --
> 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
>