Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php shorten amount of text displayed

Tags:

php

mysql

I am trying to limit the amount of text/data is being shown from MySQL not MySQL LIMIT but limiting it on the actual page like most blogs do. After certain text point they just display ...more, I know there is a function to do this in PHP but I am unable to remember its name could some one help me out with it?

like image 511
PT Desu Avatar asked Nov 29 '22 18:11

PT Desu


1 Answers

if(strlen($text)>1000){
    $text=substr($text,0,1000).' Read more';
}

you should understand that it can cut words and tags too.

like image 114
RiaD Avatar answered Dec 05 '22 16:12

RiaD