08-09-2009, 04:08 AM
|
#2 (permalink)
|
|
The Contributor
Join Date: Jul 2009
Posts: 80
Thanks: 13
|
This is my latest code, and it works great, however if the db has in its row something like the following
Quote:
Today Yahoo and Microsoft came to a deal, were Microsoft would power Yahoo search.
In return Yahoo will....
|
it seems this script stops at power Yahoo Search. instead of yahoo will... I believe it is due to the line space.
Code:
function cut_it($str,$len=400) { //default is 20, but you can switch to anything you want here on when calling it
if (strlen($str)<=$len) { return $str; }
$str = wordwrap($str,$len); //defaults to the behaviour twey setup
$str = explode("\n",$str,2); //lazy-- you could use substr/strpos, etc
$str = $str[0];
if ($str>$len) {
$str = substr($str,0,$len-3).'...';
}
return $str;
}
while($row = mysql_fetch_array($result))
{
$title = $row['title'];
print $title;
echo "<br/>";
$body = cut_it($row['body']);
print $body;
echo "<br/><br/>";
}
If you can help that would be great of you...
|
|
|
|