How do you parse a text file or a string with text and have PHP only display the first "n" amount of words? This might sound to simple so I will build upon this by also asking what would be the best/most efficient way to do this without using any class files?
...I've found this to work but is there any better? ########### $shorttext=""; $text= ereg_replace("[[:space:]]+"," ",$text); $words = explode (" ",$text); for ($i=0;$i<=30;$i++){ $shorttext .= $words[$i]." "; ############