RE: [PHP] dummy variable
| From: | John W. Holmes | Date: | Tue, 25 Feb 2003 05:35:29 +0000 |
| Subject: | RE: [PHP] dummy variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137038@lists.php.net to get a copy of this message | ||
> I have some text that outputs to a page without a variable, example:
echo
> "text";
>
> the echo has text that I would like to preg_replace.
>
> since there is no variable, is it possible to make a $dummy variable
so
> either way it replaces the text that i would like inside the echo?
>
> this is the function that I'd like to use:
>
> preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/si", "<a href=\\1
> target=_blank>\\2</a>");
>
> How do I do this?
Use output buffering. Start the buffer before the echos, capture the
output, do the preg_replace, and display the result. More info on the
manual page.
http://www.php.net/manual/en/ref.outcontrol.php
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/