note 65200 modified in function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:58:02 +0000 |
| Subject: | note 65200 modified in function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154919@lists.php.net to get a copy of this message | ||
This function will encode anything that is non Standard ASCII (that is, that is above #127 in the
ascii table)
<?php
// allhtmlentities : mainly based on "chars_encode()" by Tim Burgan
<timburgan@gmail.com> [http://www.php.net/htmlentities]
function allhtmlentities($string) {
if ( strlen($string) == 0 )
return $string;
$result = '';
$string = htmlentities($string, HTML_ENTITIES);
$string = preg_split("//", $string, -1, PREG_SPLIT_NO_EMPTY);
$ord = 0;
for ( $i = 0; $i < count($string); $i++ ) {
$ord = ord($string[$i]);
if ( $ord > 127 ) {
$string[$i] = '&#' . $ord . ';';
}
}
return implode('',$string);
}
?>
--was--
This function will encode anything that is non Standard ASCII (that is, that is above #127 in the
ascii table)
// allhtmlentities : mainly based on "chars_encode()" by Tim Burgan
<timburgan@gmail.com> [http://www.php.net/htmlentities]
function allhtmlentities($string) {
if ( strlen($string) == 0 )
return $string;
$result = '';
$string = htmlentities($string, HTML_ENTITIES);
$string = preg_split("//", $string, -1, PREG_SPLIT_NO_EMPTY);
$ord = 0;
for ( $i = 0; $i < count($string); $i++ ) {
$ord = ord($string[$i]);
if ( $ord > 127 ) {
$string[$i] = '&#' . $ord . ';';
}
}
return implode('',$string);
}
http://php.net/manual/en/function.htmlentities.php