Hi, my substr function is eating 2 byte (i think) chars such as ö,ä,ü,õ which eventually leads to having "?" in the values.
For example:
$roflmao1 = "somerandomtext";
$roflmao2 = "äöõüäöõüäöäöõü";
if(strlen("$roflmao1") > 10){ $roflmao1 = substr($roflmao1, 0, 10) . '...'; } RESULTS: somerandom...
if(strlen("$roflmao2") > 10){$roflmao2 = substr($roflmao2, 0, 10) . '...';} RESULTS: äöõüäöõüä?...
Could anyone provide a solution for this.
Thank you.
Substr eating chars
Moderator: General Moderators
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: Substr eating chars
Have a look at php multibyte functions = http://www.php.net/manual/en/intro.mbstring.php
Re: Substr eating chars
Not helping, but thanks.
if(mb_strlen($roflmao2) > 20){ $roflmao2 = mb_substr($roflmao2, 0, 20) . '...'; }
Doesnt work either.
if(mb_strlen($roflmao2) > 20){ $roflmao2 = mb_substr($roflmao2, 0, 20) . '...'; }
Doesnt work either.