Re: Interesting problem
| From: | Ken N | Date: | Thu, 29 Jun 2000 15:55:12 +0000 |
| Subject: | Re: Interesting problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3871@lists.php.net to get a copy of this message | ||
That happily produces an empty file, :) O'well at least it was funny,
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 Thu, 29 Jun 2000, TomHenry wrote:
> Sorry for the incomplete solution --
> the completed solution would work as follows
>
> $linesbefore="COMMENTS\nHERE\n";
>
> > > > while(list($line_num, $line) = each($httpd_conf))
> > > > {
> > > > if(ereg("$domain", $line))
> > > > {
>
> // build up the contents of httpd_new by cat'ing all the lines together
> $line .= $linesbefore . ereg_replace("$line", "#REMOVED $date $line",
> "$line")."\n"; // may need to add a line feed at end -- untested
>
> > >
> > > > }
> > > > }
> > > >
>
> // place the fputs outside the loop
> fputs($httpd_new,"$line");
>
>
> HTH a little more,
> Tom Henry
>
>
>
> At 03:10 PM 6/29/00 +0000, Ken N wrote:
> >Ya, that's my problem, how do I get lines before? While moving through the
> >while loop I can only access the item I am currently on, is there some way
> >I can access the previous element. when ereg matches on that current
> >element.
> >
> >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 Thu, 29 Jun 2000, TomHenry wrote:
> >
> > >
> > > Try something like
> > >
> > >
> > > HTH,
> > > Tom Henry
> > >
> > >
> > > At 02:57 PM 6/29/00 +0000, Ken N wrote:
> > > >Hi,
> > > >
> > > > This has got me a little confused. I am using list to plow
> > through
> > > >an httpd.conf file and remove entries, however I have a little problem. I
> > > >can use ereg_replace to add comments to the virthost entry but, what about
> > > >the lines in before and after? Is there a way I can say to comment put the
> > > >say two lines before the where I matched the reg exp? If you look at the
> > > >code maybe it will make a little more sense.
> > > >
> > > > while(list($line_num, $line) = each($httpd_conf))
> > > > {
> > > > if(ereg("$domain", $line))
> > > > {
> > > > $line = ereg_replace("$line", "#REMOVED $date $line",
> > > > "$line");
> > > > }
> > > > fputs($httpd_new,"$line");
> > > > }
> > > >
> > > >Thanks
> > > >Ken
> > > >
> > > >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
> > >
> > > --------------------------------------------------------------------
> > > Strategic Business Systems (978) 745-2332
> > > http://BusinessWebs.com/
> > > --------------------------------------------------------------------
> > >
> > >
> >
> >
> >--
> >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
>
> --------------------------------------------------------------------
> Strategic Business Systems (978) 745-2332
> http://BusinessWebs.com/
> --------------------------------------------------------------------
>
>