note 80138 deleted from function.str-word-count by felipe

From: Date: Thu, 03 Jan 2008 01:33:42 +0000
Subject: note 80138 deleted from function.str-word-count by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134679@lists.php.net to get a copy of this message
Note Submitter: noreply at capacitywebsolutions dot com ---- /* Break the long text into small text as per your requirement - (Breaking with words) parameters - 1) Original String 2) Show Number of words of the your string */ function snippet($string,$word_count=10) { $ArrayWords=str_word_count($string, 1); // Return the words in Array $ReturnString=""; for($i=0;$i<$word_count;$i++) // Concate the words as per word count =10 { if($ReturnString=="") $ReturnString=$ArrayWords[$i]; else $ReturnString=$ReturnString." ".$ArrayWords[$i]; } return $ReturnString=$ReturnString." ..."; // Add the string '...' at last and return }

« previous php.notes (#134679) next »