This forum is now read-only. Please use our new forums at

864 points
Submitted by
Matti Järvinen
over 3 years ago

strlen vs. mb_strlen substr vs. mb_substr

I think it is "dangerous" to teach people to use strlen and substr. In practice mb_strlen and mb_substr are used instead since strlen doesn't work right with UTF-8 strings like "ä" -> strlen("ä") == 2 mb_strlen("ä",'UTF_8') == 1

For PHP code that works globally using strlen and substr is not an option.

0 votes


Hey Matti,

Unfortunately, I don't think the creator of this course plans on updating it, but that's definitely very interesting. Since Codecademy focuses on being global, I'm surprised that they didn't notice that the course doesn't work with special characters.

2835 points
Submitted by
Zeke Y
over 3 years ago