I have two string that i want to limit to lets say the first 25 characters for example. Is there a way to cut off text after the 25th character and add a ... to the end of the s
echo substr($str,0,25)."...";
Would do the trick, but if you are dealing with words, you might want to cut off on word boundries so you don't have partial word doig this: The quick bl...
So to do that (crude off the top of my head):
$words = split(" ", strlen($str));
for($i = 0,$j=0; $i< 25 && $j < sizeof($words) ;$j++)
{
$i += strlen($words[$j]);
echo $words[$j]. " ";
}
echo "...";