Re: ereg_replace
| From: | () | Date: | Mon, 09 Jul 2001 08:43:55 +0000 |
| Subject: | Re: ereg_replace | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-10174@lists.php.net to get a copy of this message | ||
In article <20010629192917.1303.qmail@web11801.mail.yahoo.com>, Olinux O wrote:
>What I'm doing is using ereg_replace in this form:
>$LargeString = ereg_replace("<tag>.*</tag>",
>"replacement", "$LargeString");
>but what I get is the string with the replacement in a
>way I don't actually want. It replaces the part of the
>string that begins with THE FIRST TAG <tag> and that
>ends with THE LAST TAG </tag>.
Dunno of its helping but we had a simular prob. I wrote a small class that
allows us to check for allowed tags.
<code>
........ class declarations .........
$allowedtags = array (
'<br>' => '[br]',
'<p>' => '[p]',
'</p>' => '[/p]',
'<strong>' => '[strong]',
'</strong>' => '[/strong]',
'<b>' => '[b]',
....... etc.......
while ( list ($key, $val) = each($allowedtags)) {
$trans = str_replace ($key, $val, $trans);
}
$trans = strip_tags(stripslashes($trans));
reset($allowedtags);
while ( list ($key, $val) = each($allowedtags)) {
$trans = str_replace ($val, $key, $trans);
}
return $trans;
</>
Regards,
Hans