How can I convert the upper-case html entity characters to their lowercase?
$str = "É"; //É
$res = strtolower( $str );
echo $res;
How can I convert the upper-case html entity characters to their lowercase?
$str = "É"; //É
$res = strtolower( $str );
echo $res;
Just use the right function for it:
$strLower = mb_strtolower($str, 'HTML-ENTITIES');
The PHP Multibyte String extensionDocs has an encoding for HTML entities (See list of all supported encodingsDocs).
$str = "É"; //É
$res = mb_strtolower(html_entity_decode($str,ENT_COMPAT|ENT_HTML401,'UTF-8'),'UTF-8' );
echo $res;
Convert the hexit to decimal and add 32, convert back to hexit.
Or using mbstring
:
$res = mb_strtolower(mb_convert_encoding($str, 'UTF-8', 'HTML-ENTITIES'), 'UTF-8')
On my server, I don't have the mbstring
extension installed. For a better, cross-server solution you should use this instead:
echo htmlentities(strtoupper(html_entity_decode($str)));