I would like to count the length of a string with PHP. The string contains HTML entity numbers, which inflate the number of characters that are counted: a dash is –
which is counted as 7 when I only want it to count as 1.
How do I convert the html numbered entities to a form where special characters are only counted with a length of 1?
Example string:
Goth-Trad – ‘Cosmos’
The code:
$string = html_entity_decode('Goth-Trad – ‘Cosmos’');
echo strlen($string);
produces '38', when I'm looking for '20'. What is going wrong?