If your strings may contain Unicode (multi-byte) characters and you don’t want to break these, replace substr
with one of the following two, depending on what you want:
Limit to 142 characters:
mb_substr($var, 0, 142);
Limit to 142 bytes:
mb_strcut($var, 0, 142);