sorry, my previous post had an error. replace the 1000 with strlen($haystack) to handle strings longer than 1000 chars.
btw. This is an issue with the mbstring functions. you can't specify the $encoding without specifying a $length, thus this reduces the functionality of mb_substr compared to substr