The following works fine:
$entry = substr($entry,0,500)."...";
and I know that it will cutoff any word at the 500th character, but is there a way to get it to cutoff $entry and the last whole word?
...cutoff $entry and the last whole word?
If you do that you'll have nothing but "...". Do you mean just the whole last word?
You might be able to do it with regular expressions. It's too early in the morning for me to try writing one for you, but if you're new to regular expressions, try this tutorial:
http://etext.lib.virginia.edu/services/helpsheets/unix/regex.html
Or see this thread.
Installer wrote:If you do that you'll have nothing but "...". Do you mean just the whole last word?
If you look at the top story on http://www.littlesaints.net, you will see that this text:
The chief judge in Saddam Hussein's genocide trial told the ex-president that "you were not a dictator," sparking Kurdish demands he be replaced. The judge already had rejected prosecution demands he step down for allegedly favoring the defense. Judge Abdullah al-Amiri, a Shiite Arab, made the comment Thursday after Saddam, a Sunni, challenged testimony by a Kurdish farmer who said the ousted president ordered him to "shut up" when he begged for the release of nine missing relativ...
The chief judge in Saddam Hussein's genocide trial told the ex-president that "you were not a dictator," sparking Kurdish demands he be replaced. The judge already had rejected prosecution demands he step down for allegedly favoring the defense.
Judge Abdullah al-Amiri, a Shiite Arab, made the comment Thursday after Saddam, a Sunni, challenged testimony by a Kurdish farmer who said the ousted president ordered him to "shut up" when he begged for the release of nine missing relativ...
and that code works but it is cutting off the word, which is fine, but to me it would be better to make it get the last whole word around the 500th character. Does that make sense?
Yet another solution:
$cut = substr($text, 0, 500); $new_text = substr($cut, 0, strrpos($cut, ' '));
Installer wrote:Yet another solution:$cut = substr($text, 0, 500); $new_text = substr($cut, 0, strrpos($cut, ' '));
That was it Installer!!!!!!! Thanks 😃