Jump to content

String length abbreviator


mort

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 :)
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.