For a while I’ve been amazed that PHP was giving me the wrong number of characters in a string with strlen(). Then I realized that it had the letter “ñ”.
echo strlen(‘nail’) // output 4
Continuing with my tests, I see that it also happens when the letters have accents, any accented letter or, for example, the “ç”.
echo strlen(‘á’) // display 2
Why is this happening? How can I display the correct number of characters?