When I use substr() I get a strange character at the end
substr()
$articleText = substr($articleText,0,500);
I have an output of 500 c
Use mb_substr instead, it is able to deal with multiple encodings, not only single-byte strings as substr:
$articleText = mb_substr($articleText,0,500,'UTF-8');