2

I have this code case strlen($search_term) > 15: in my switch statement. I cannot figure out why Greek characters are parsed different. For example a string in Latin with the length of 10 passes the case but if the string is in Greek, it does not.

Except the solution i would appreciate an explanation of my problem.

Makis
  • 1,214
  • 3
  • 16
  • 40

1 Answers1

3

strlen() returns the bytes of the string, not the length.

Many greek characters are 2 bytes instead of 1, thats why you think you take wrong results.

Use mb_strlen() instead : http://lt.php.net/manual/en/function.mb-strlen.php

Hope this helps

IseNgaRt
  • 601
  • 1
  • 4
  • 22