/ Published in: PHP
split_to_chunks splits the string up into an array with elements containing 140 characters <b>or less</b>. This enables you to keep words intact when sending automated twitter messages.
$to is needed in order to subtract from 140 the amount of characters allowed. This is important because a long username could create problems with messages being too long. This could be done pragmatically, and would be relatively simple to do, but was not needed in my case and so was not implemented.
$text contains a string containing any amount of characters - including under 140.
$message is an array which gives the message <b>minus</b> the username at the front.
$to is needed in order to subtract from 140 the amount of characters allowed. This is important because a long username could create problems with messages being too long. This could be done pragmatically, and would be relatively simple to do, but was not needed in my case and so was not implemented.
$text contains a string containing any amount of characters - including under 140.
$message is an array which gives the message <b>minus</b> the username at the front.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* split_to_chunks by John Hamelink 2010. This code is in the PUBLIC DOMAIN. */ function split_to_chunks($to,$text){ $i=0; $message[0]=""; foreach ($text_arr as $word){ $message[$i] .= $word; } else { $message[$i] .= $word . ' '; } } else { $i++; $message[$i] = $word; } else { $message[$i] = $word . ' '; } } } return $message; }