This is the function I use
function sms_chunk_split($msg) {
$msg = preg_replace('/[\r\n]+/', ' ', $msg);
$chunks = wordwrap($msg, 160, '\n');
return explode('\n', $chunks);
}
It splits a long SMS message into an array of 160 byte fragments, dividing word boundaries.
source
share