How to cut the string without breaking any words
<?php function Cut($string, $max_length){ if (strlen($string) > $max_length){ $string = substr($string, 0, $max_length); $pos = strrpos($string, ” “); if($pos === false) { return substr($string, 0, $max_length).”…”; } return substr($string, 0, $pos).”…”; }else{ return $string; } } $string = ‘How to cut the string without breaking any words’; echo Cut($string,30); ?> The output is
Read more

12. Dec, 2007



