PDA

View Full Version : Another easy one for the experienced...



GFX.Wiz
October 27th, 2004, 11:26 AM
This one should be easy for anyone other than me...I couldn't find any documentation on the 'net for this...

When I query the database I get my results. One of the results is a headline that can be up to 255 characters in the database. However, in some instances I only have enough room to display the first 35 characters. How can I truncate the output followed by a "..." if it's longer than 35 characters?

example:

- in DB: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris ipsum justo, fermentum ornare, pulvinar vel, ultrices ut, turpis."

- required output: "Lorem ipsum dolor sit amet, consect..."

Thanks for any input!

peace,
GFX.Wiz

CyanBlue
October 27th, 2004, 11:39 AM
Howdy... :)

You can use substr() function to do that...

You can do that from the PHP(or any other language you are using) or in Flash to do so...


<?php
$str = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris ipsum justo, fermentum ornare, pulvinar vel, ultrices ut, turpis.";
$str = substr($str, 0, 35) . "...";
echo($str);
?>

GFX.Wiz
October 27th, 2004, 11:49 AM
Howdy... :)

You can use substr() function to do that...

You can do that from the PHP(or any other language you are using) or in Flash to do so...


<?php
$str = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris ipsum justo, fermentum ornare, pulvinar vel, ultrices ut, turpis.";
$str = substr($str, 0, 35) . "...";
echo($str);
?>
Howdy again CyanBlue :beam:

You rock! I was able to take your info and use it for my particluar application and it worked perfect.

Thanks SO much!

I think I have one more post to make later today for one more issue I need resolved but I am going to give it the old college try before I do :thumb:

peace,
GFX.Wiz