[thelist] PHP: How to include a variable in DB text?

muinar evolt at muinar.com
Tue Jul 8 10:10:05 CDT 2003


At 00:32 05.07.03, you wrote:
>You can't really get PHP to see it as a variable, as a variable is an 
>internal condition
>to it's interpreter which is lost when it outputs flat data to mySQL.
>However, you can make your PHP script handle the data as containing a 
>variable, and then
>replace that variable with your text, e.g.
>
>Lorem ipsum dolor sit $var   --->  submit  --->
>
>$text = 'Lorem ipsum dolor sit %foo%';
>
>$foo = 'amet';
>$text = str_replace('%foo%',$foo,$text);
>echo $text;  // --->  Lorem ipsum dolor sit amet

Thanks for all the suggestions! I went with str_replace,
so I have control over what it will do.

Mike



More information about the thelist mailing list