I would like to calculate the length of a string with PHP. The string contains the numbers of HTML objects that inflate the number of characters that are counted: dash – which is considered 7 when I want it to be considered 1.
How to convert objects with the html number to a form where special characters are taken into account only with a length of 1?
Example line:
Goth-Trad – ‘Cosmos’
Code:
$string = html_entity_decode('Goth-Trad – ‘Cosmos’'); echo strlen($string);
produces "38" when I search for "20". What is going wrong?
source share