Finding variable names in strings, and replacing with values?
| From: | Nick Richardson | Date: | Sat, 09 Mar 2002 01:26:00 +0000 |
| Subject: | Finding variable names in strings, and replacing with values? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87838@lists.php.net to get a copy of this message | ||
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 --
--------------------------------------------------------------