[thelist] [php] ereg_replace

Paul Bennett paul at teltest.com
Mon Nov 18 18:32:00 CST 2002


This is one of those (rare) occasions where something worked a lot
better than expected and I want to know why.
I have html code in a database that has been "encoded" using
htmlentities, so
<p class="Container">text</p>
now looks like:
&lt;p class=&quot;Container&quot;&gt;text&lt;/p&gt;
( Disclaimer - This is for a personal CMS project, so don't ask about
the logic of storing it this way, and yes,  I *am* going to change it
later on :) )
I have tested using ereg_replace("&lt;", "<", $storedHtmlStringValue);
 to "unescape" the html in the database and output it as regular html,
I figured that the above function would only replace the"<" character
but it replaces both the "<" and the ">" character.Yes,  I have rtfm and
from what is stated, the function should only replace one character not
2. Any ideas???

--
Paul Bennett
Internet Developer
Teltest Electronic Design
--------------------------
Phone : 64 4 237 0767
Web : http://www.teltest.com
Wap : http://wap.teltest.com
Email : paul at teltest.com
--------------------------






More information about the thelist mailing list