I know mb_ is for dealing with utf8 characters, still it wont solve my problem.
So I have this string:
óóóóóóóóóóóóóóóóóóóóóóóóóóóóóóó
mb_substr ($oooo, 0,17, 'UTF-8');
óóóóóóóóóóóóóóóóó&oac
so the last character damages.
I know mb_ is for dealing with utf8 characters, still it wont solve my problem.
So I have this string:
óóóóóóóóóóóóóóóóóóóóóóóóóóóóóóó
mb_substr ($oooo, 0,17, 'UTF-8');
óóóóóóóóóóóóóóóóó&oac
so the last character damages.
Your string is not actually
$str = 'óóóóóóóóóóóóóóóóóóóóóóóóóóóóóóó';
Your string is actually:
$str = 'óóóóóóóó...';
When looked at in the browser, the browser will of course render "ó", but that's of no interest to PHP.
The best solution is to get your content into the actually UTF-8 encoded characters "óóóóóóóóóóóóóó", then use your code as is. To make this work on your current string, you need to decode the HTML entities first:
$str = 'óóóóóóóó...';
$str = html_entity_decode($str, ENT_COMPAT, 'UTF-8');
echo mb_substr($str, 0, 17, 'UTF-8');
You'll then of course need to take care of the output encoding, since you're now outputting actual UTF-8 which the browser needs to understand. See UTF-8 all the way through.