I have a PHP project ( Using laravel ) and I need to show just part of an article in the view . For example this is the full content of article :
Hello World It is my First Post and I decided to share it on my personal blog .
and I wanted to show part of that in the recent posts part such this :
Hello world it is ...
I made a function but it doesn't work when I want to limit the text ( But there is no problem with short texts ) This is my function :
function limitText($text,$length=300) {
if(strlen($text)<$length) {
$new = $text."...";
return $new;
}
$new = substr($text,0,$length);
$new = $new."...";
return $new; }
any idea or suggestion ?
via Dana Mirafzal