To anyone else who had the same problem, I thought i'd share the solution
that was passed on to me. It was suggested that counting the # of characters
in a string would work, and it does, but a better way to do it as not to cut
yourself off in mid sentence is to count the # of actual words.
-- snipity snip --
function make_newsbite($body, $len){ // $body is
article $len is maxwords
$words = Array();
preg_match_all('/([^ ]*) */', $body, $words); // separate
string into words array
for($n = 0; $n <= $len; $n++){ // for count words to len
$newsbite .= $words[0][$n] . ' '; // append words
to $newsbite
}
return $newsbite;
}
-- snipity snip --
use it like
$lilnews = make_newsbite($bignews, 80);
Hope this solution helps others.
A big thanks to Don Read for this code.
if ( strlen($foo) > 100) {
echo substr($foo,0,100), ' <A HREF="/showmore.php">More ...</A>';
} else {
echo $foo;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]