Problem with character decoding [duplicate]

0

I'm using a function to limit the amount of characters that are shown, something like this:

 function blabla ($string, $maxSize) {
    if (strlen($string) > $maxSize)
                $string = substr($string, 0, $maxSize) . ' [...]';
            return $string;
}

But it is returning some bugged characters like: "title" gets "Title", but when I do not use the function the string comes normal, with no bugged characters. how can I resolve this?

I'm using this in the header:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
asked by anonymous 28.11.2016 / 03:19

1 answer

0

Use mb_substr() instead of substr() manual . An excellent answer in another context, but that fits your question: Problem using substr in text with PHP

    
28.11.2016 / 03:36