I'm trying to split a SMS message if it hits the limit of 160 characters.
This is my current code.
$messageparts = str_split($message, 160);
foreach($messageparts as $parts){
sms($numbers, $parts);
}
My current problem
- My SMS message includes "\n" but when i use strlen, it only counts "\n" as 1 character while the SMS server count "\n" as 2 characters.
- Currently it will split the SMS message when it hits the limit of 160 characters which is quite ugly. Example being:
SMS 1 Item A $160 Item B $170 Ite SMS 2 m C $180
As you can see from the example, its quite a bad split. I'm looking for someone who can help so that the function can first split by character limits then delimit by the last "\n". So that it will be as the following example.
SMS 1 Item A $160 Item B $170 SMS 2 Item C $180