Convert all HTML special chars to UTF-8 in PHP?

21,489

Use html_entity_decode() and explicitly specify the charset:

$string = html_entity_decode($string, ENT_QUOTES, "utf-8");

for future reference: PHP string functions

Share:
21,489
Admin
Author by

Admin

Updated on January 24, 2020

Comments

  • Admin
    Admin over 4 years

    Can somebody help me? How can i convert all HTML special chars to UTF-8 Example:

    Hello Word! P&H
    

    convert to:

    Hello Word! P&H
    
  • BoltClock
    BoltClock over 13 years
    Would be lovely if SO actually told me the very moment your answer shows up instead of waiting at least 1 whole minute or until I hit Post Your Answer...
  • Pekka
    Pekka over 13 years
    @BoltClock yeah, that mechanism is somehow broken, I've noticed too.