Jump to content

Archived

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

mort

String length abbreviator

Recommended Posts

Hey

You know when you get extra long URL's and some forums seem to abbreviate it using a few ...'s once it hits a certain length. Anyone point me in the right direction, or have a function to do this?

Want to use it for a) splitting up long strings, and b) for going through a string to look for stupidly long sections in the string not seperated by a space (which can destory tables and css positioning real good.

cheers :)

Share this post


Link to post
Share on other sites
$address="http://www.thisisaveryveryveryveryveryveryveryveryloooooooongurl.com";
echo '<a href="'.$address.'">'.substr($address, 0, 15).'...</a>';

u will need to add somthign to check that it is over 15 chars using strlen to return the value but there's the basics

Regards
Liam

Share this post


Link to post
Share on other sites

×

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.