Posted by gosha bine on 09/24/07 18:15
RageARC wrote:
> I have:
>
> $string = "text ... [COLOR]FFFFFF[/COLOR] text... ";
> $replacement = "<div id='THECOLOR'>THECOLOR</div>";
>
> Where THECOLOR has to be the color the user inserted inside the tags.
> I could use preg_replace, but I don't know regex. Can you help me?
>
try
preg_replace('~\[COLOR\](.+?)\[/COLOR\]~',
"<div id='$1'>$1</div>",
$string);
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
[Back to original message]
|