7

How can I convert the upper-case html entity characters to their lowercase?

$str = "É"; //É

$res = strtolower( $str );

echo $res;

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

Purple Coder
  • 319
  • 1
  • 13
Martin
  • 2,007
  • 6
  • 28
  • 44

4 Answers4

8

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).

hakre
  • 193,403
  • 52
  • 435
  • 836
7
$str = "É"; //É

$res = mb_strtolower(html_entity_decode($str,ENT_COMPAT|ENT_HTML401,'UTF-8'),'UTF-8' );

echo $res;
dev-null-dweller
  • 29,274
  • 3
  • 65
  • 85
1

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')
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
0

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)));
Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107