As you can see the saved string has html code within, and when the html_entity_decode is performed upon the string this is being included within the character count.
With a slight adjustment to the code by adding – ENT_QUOTES,”UTF-8″ we get the correct amount of characters within the string as seem by a webpage after decode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
echo $string1 = html_entity_decode("We're the smartest SEO Agency. We love SEO, so let's grab a coffee & find out how we can make you shine in search with our SEO!"); echo "<br>"; echo strlen($string1); echo "<br>"; echo $string2 = html_entity_decode("We're the smartest SEO Agency. We love SEO, so let's grab a coffee & find out how we can make you shine in search with our SEO!",ENT_QUOTES,"UTF-8"); echo "<br>"; echo strlen($string2); |