• 10th, Jun 2010

PHP Text Manipulation Functions

/**
* Text Manipulation Functions
* www.unexpectedit.com
*/
function html_cut_text($text,$limit) {
	$max_code=8; // max for special code like ‰ á ...
	if(($limit<>0)&&(strlen($text)>$limit)) {
		$pos=strpos(substr($text,0,$limit+$max_code),';'); //find ;
	if($pos) // cut when pass ;
		$text=substr($text,0,$pos+1);
	else //cut at limit
		$text=substr($text,0,$limit);
	return($text."...");
	}
	else
		return($text); // return
}

Tags: , , , , ,

Leave a Reply

*

© 2010 unexpected[it]. All Rights Reserved.