…forget that every Greek character is counted as 2 by the strlen function in PHP. So if you have say a string "Γειά" the strlen will return 8.
Try using MB_STRLEN() instead. If you know the encoding you can save time.