PHP convert special characters to HTML entity PHP convert special characters to HTML entity wordpress wordpress

PHP convert special characters to HTML entity


Here is what I came up with to convert all of the characters you can modify it further to only convert characters in the range you need.

$s = 'abc🔹def';$a = preg_split('//u', $s, null, PREG_SPLIT_NO_EMPTY);foreach($a as $c){    echo '&#' . unpack('V', iconv('UTF-8', 'UCS-4LE', $c))[1] . ';';}