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
Looks like you're slicing a unicode character in half there. Use mb_substr instead for unicode-safe string slicing.