SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    May 2003
    Location
    sitepoint
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ellipses if title to long

    How would I go about finishing off a title with eliipses if it is to long. I'm pulling titles into a css table based on ranking, some are longer than others, say the title is, "This title is to long and needs to be shortened." I want it to be about 20 characters long when showing the link to the actual page. So the link should be like, "This title is to long..." Any ideas?
    Half way to nowhere

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    substr()

    see the manual and read the user comments for suggestion on how to prevent it from cutting in the middle of a word.

  4. #4
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    Better method above, particularly if you don't want to slice words

    You could use the string as an array characters and display characters 0 to 19, but, this probably the best way to do it. Adding the elipses is easy after that.
    ]


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •