i have a mysql database and a table full of information, specifically a column of product descriptions. This column is used in my scripts twice. Its max length is 1000 characters.
One of the uses for this information is a brief description of any given product. I would like to display a shortened version of the description that I have just mentioned, so it will be say for instance 200 characters long.
Now, using PHP I would like to append the string with "..." (3 dots) at the point where it reaches 200 characters. So basically only the first 200 characters are displayed.
How would I go about something like this? I am sure it will be a fairly simple task but the internet is a big place to look for something you don't know the name of :)
If anyone could help in this regard, with an example or some links relating to the relevant functions that would be great. Thanks a lot!
You can achieve this using substr.
$string = substr($string,0,197) . "...";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With