How to send messages in reverse order?
I'm using the code below to split a long message into multiple short
messages. What is the easiest way to reverse the sending order, so the
last message gets send first?
(messages should be send in this order 3>2>1 instead of the current 1>2>3)
function split_to_chunks($to,$text){
$total_length = (137 - strlen($to));
$text_arr = explode(" ",$text);
$i=0;
$message[0]="";
foreach ($text_arr as $word){
if ( strlen($message[$i] . $word . ' ') <= $total_length ){
if ($text_arr[count($text_arr)-1] == $word){
$message[$i] .= $word;
} else {
$message[$i] .= $word . ' ';
}
} else {
$i++;
if ($text_arr[count($text_arr)-1] == $word){
$message[$i] = $word;
} else {
$message[$i] = $word . ' ';
}
}
}
$length = count($message);
for ($i = 0; $i < $length; $i++) {
if($i < $length-1){
$status = new Tweet();
$status->set($message[$i]."...");
} else {
$status = new Tweet();
$status->set($message[$i]);
}
}
}
No comments:
Post a Comment