note 65200 deleted from function.htmlentities by cmb
| From: | cmb@php.net | Date: | Sun, 01 Dec 2019 08:29:52 +0000 |
| Subject: | note 65200 deleted from function.htmlentities by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213291@lists.php.net to get a copy of this message | ||
Note Submitter: anonymous
----
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);
}
?>