If you want it to only show whole words then you could try this:
PHP Code:
<?
$string = "Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah.";
$words = explode(" ", $string);
for ($i = 0; $i <= 5; $i++) {
echo $words[$i]. " ";
}
?>
The only way I know how to do it so it will only show the first 20 charaters is to use if statements for it like
PHP Code:
<?
$string = "Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah.";
for ($i = 0; $i <= 20; $i++) {
if ($string[20] == " ") {
echo $string[19];
} else {
echo $string[$i];
}
}
?>
But that doesn't really work well cause you would have to have it find the word right before the cutopff word.
Bookmarks