Forum Moderators: coopster

Message Too Old, No Replies

Convert html into decimal codes

         

ocon

11:57 pm on Oct 20, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have a string that looks like this:

$str="<title>Title</title>";

However, I need it to look like this:

$str="&#60;title&#62;Title&#60;/title&#62;";

Currently I'm using the following code to convert the former to the latter:

$old=array("\"","<",">");
$new=array("&#34;","&#60;","&#62;");
$title=str_replace($old,$new,"<title>Title</title>");

Is there a built in function to do this for me?

rawurlencode, and urlencode don't work for what I need, is there one that might?

eeek

12:04 am on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



[php.net...]

ocon

1:07 am on Oct 21, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you for the link.

I also have tried using htmlspecialchars, but it converts some characters such as brackets into &lt; and &gt;

Are there any functions, or options of htmlspecialchars that forces the conversion into decimal codes only?

eeek

1:12 am on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why?