简体   繁体   中英

Strlen() and Non-Latin Characters

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM