Jump to content

i want to echo only 200-300 characters or 1-2 lines of data means ...


shahzad

Recommended Posts

$query_data['Comments'];

i have one comments filed but what i want now is.

 

if data is more than 1-2 lines or more than 100 characters end user with see only 2 lines and ... at the end

so that he can click read more to view all.

 

please help me with it.

 

Thanks in advance

If its text overflow you cannot do it with PHP (as far as I know)

Your best bet is to pick a max length that will look good in your layout and trim it down to fit nicely..

 

$max_len = 300; // Only show 300 characters //
echo (strlen($string) > $max_len ? substr($string,0,$max_len).'...' : $string);

will do the trick (UNTESTED)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.