Hi, It's possible to display the first 3 or 4 words from a huge text field of a mysql database? thanks in advance.
If you want PHP script write that you want PHP script! I just answer your question! You can do by the PHP functions explode(). Get the huge text from the mysql database, explode the text by space ( $exploded_huge_text = explode(" ",$huge_text) ), then concatenate the first 3 or 4 words ( $string = $exploded_huge_text[0]." ".$exploded_huge_text[1]." ".$exploded_huge_text[2]." ".$exploded_huge_text[3] ). I think this is what you want.
depending on txt size maybe quicker doing $start = 0; $cnt = 0; $outstr = ""; while ($cnt<3) { $sub = substr($huge,$start,$start+1); $start++; if ($sub=="") $cnt++; $outstr .= $sub; } PHP:
Check this if your text is comming from db http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr