Hi I had a database and a column called "details" in it. I need to select data from that column and show only limited characters of it.

For eg:
Original : The quick lazy fox jumps over a lazy dog.
Display : The quick lazy ...

How can I do with php and mysql....
Please help me.
Thanks in advance
Rajeesh

Use substr function. Note, I also used strpos in the example to ensure that the last word isn't broken up.

<?php
$str="The quick lazy fox jumps over a lazy dog.";
$space=" ";
$sppos=strpos($str,$space,10);
$str=substr($str,0,$sppos);
$str.=" ...";
echo $str;
?>

Example without strpos:

<?php
$str="The quick lazy fox jumps over a lazy dog.";
$str=substr($str,0,14);
$str.=" ...";
echo $str;
?>

Thank you Thank you Thank you for your kind support

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.