Clicky

Hi experts,

I want to use the htmlentities() function for all characters.
I mean htmlentities("http://www.") returns "http://www."
And I would like to get
"http://www."
as result.
How do I do that?
Thanks

asked 12/13/2011 06:49

Alwin's gravatar image

Alwin ♦♦


1 Answers:
Try this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
<?php
function safeentities($string) {
        $strout = "";
        for ($i = 0, $n = strlen($string); $i < $n; $i++) {
                $ord = ord($string[$i]);
				$strout .= "&#{$ord};";
        }
        return $strout;
}

echo safeentities("http://www.");
?>


The output is:

1:
&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#119;&#119;&#119;&#46;
link

answered

StingRaY's gravatar image

StingRaY

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×104
×1
×191

Asked: 12/13/2011 06:49

Seen: 271 times

Last updated: 12/13/2011 08:48