PHP: convert uppercase html entity to lowercase

How to convert upper lowercase characters of an html object to their lowercase letters?

$str = "É"; //Γ‰ $res = strtolower( $str ); echo $res; 

http://codepad.viper-7.com/Zf3RTe

+7
source share
4 answers
 $str = "É"; //Γ‰ $res = mb_strtolower(html_entity_decode($str,ENT_COMPAT|ENT_HTML401,'UTF-8'),'UTF-8' ); echo $res; 
+7
source

Just use the correct function for it:

 $strLower = mb_strtolower($str, 'HTML-ENTITIES'); 

The PHP extension Multibyte String Docs has an encoding for HTML objects (see the list of all supported Docs encodings for a list ).

+8
source

Convert 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') 
+1
source

On my server, I do not have the mbstring extension installed. For a better cross-server solution, you should use this instead:

 echo htmlentities(strtoupper(html_entity_decode($str))); 
0
source

All Articles