Page 1 of 1

Replace strings in text document?

Posted: Thu Jun 09, 2005 9:02 pm
by Rob02
Hey Guys,

For the life of me I can't figure out how to do this, and since I don't know the proper terms, I can't search the net for it.

Basically I have a mailing list program that has a regular text box titled "message". The message is then sent over to a php script that just takes the message and emails it to all the users in the MySQL database using arrays.

How would I go about having php analyze the message and change the strings to the data in the MySQL DB?

For example, if I typed %fname%, it would replace it with data in the fname column of MySQL?

Am I explaining myself right? Sorry for the confusion!

Thanks

Posted: Fri Jun 10, 2005 2:17 am
by Syranide
str_replace, will do the trick for replacing in your strings.
then just do some magic MySQL-statement to get the "from" and "to"-values which you feed to str_replace.