Truncate text to specified character limit without cutting word
Self explanatory function to get limited text from long paragraph.
function limit_text($mystring, $no_of_chars, $append_text)
//$mystring -> Text string that need to be process
//$no_of_chars -> Number of character to be display
//$append_text -> Append text at the end of truncated text to show more to read.
//like “Continue..”,”….”, “[..]”
$no_of_chars = strpos($mystring,” “,$no_of_chars);
// Seeking position of space after allowed character length to prevent word from cut down.
$rstring = substr($mystring,0,$no_of_chars).$append_text;
// retrieve sub string till allowed character and add append text
do you have an example of this execution?
thanks. do you have an example of this being used?
nevermind. i got it. thanks again.
Thanks, let me know if you have any trouble using this function.