Re: Finding variable names in strings, and replacing with values?
| From: | Jan Grafström | Date: | Sat, 09 Mar 2002 07:16:08 +0000 |
| Subject: | Re: Finding variable names in strings, and replacing with values? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-87859@lists.php.net to get a copy of this message | ||
Hi Nick!
http://www.php.net/manual/en/function.str-replace.php
Regards,
Jan
"Nick Richardson" <esoteric.web@gte.net> skrev i meddelandet
news:NKEBIAJBBAHEPAJBECDLKEMBCEAA.esoteric.web@gte.net...
> Been working on this one for quite awhile, and it's probably a fairly easy
> solution, but i can't find it... so thought i would ask.
>
> I'm opening a file, and going through it line by line. I need for find
> places where the line contains %value% and replace it with $value.
>
> So if the line says <body bgcolor=%bgcolor% text=%textcolor%
> link=%linkcolor%>, i need to replace the text where the %% stuff is and
set
> it to $bgcolor,$textcolor,or $linkcolor respectively. -
>
> I'm sure this can be done, but i'm just no good w/ the pattern matching
> stuff... so if anyone has any ideas on this, please let me know!!!
>
> Thanks
>
> //Nick Richardson
> //esoteric.web@gte.net
> //webmaster@moderngarage.com
> --------------------------------------------------------------
> -- We must come to see that the end we seek, is a society --
> -- at peace with itself. A society that can live with its --
> -- concience. That will be a day not of the white man, not --
> -- of the black man... That will be the day of man, as man! --
> -- -Dr. Martin Luther King Jr. --
> -- -March 25th, 1965 --
> --------------------------------------------------------------
>