Search code examples
phphtmlspecial-charactershtml-entities

Convert html special characters into numeric codes with PHP


Let's say I have a string $a = "à". I want to convert it to html entities.

$b = htmlentities($a); // à

Instead, I want it to be converted to its numeric version: "à" How can I do that?


Solution

  • Expanding on my comment: Look at http://php.net/manual/en/function.ord.php

    $a = "à";
    $b = ord($a); //224