note 10193 deleted from function.wordwrap by jimw

From: Date: Fri, 14 Dec 2001 20:37:44 +0000
Subject: note 10193 deleted from function.wordwrap by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22766@lists.php.net to get a copy of this message
An update to the previous note. ------------------------------- This will return exactly how many words you tell it to, and append with whatever you specify. function cut_string($string_to_cut, $number_words, $append="..") { $string = explode(" ", $string_to_cut); for($x=0; $x < $number_words; $x++) { $string_return .= $string[$x] . " "; } $string = substr($string_return, 0, -1); $return_string = $string.$append; return($return_string); } Usage: print(cut_string("This is a test",2)); Output: This is..

« previous php.notes (#22766) next »