Results 1 to 3 of 3

Thread: Putting ... at the end of a title (substr question)

  1. #1
    Join Date
    Oct 2012
    Posts
    147
    Thanks
    18
    Thanked 1 Time in 1 Post

    Default Putting ... at the end of a title (substr question)

    I've shortened titles to 60 characters. How do I tell this code to show three dots ... at the end of a title if the that title is more than 60 characters long and show nothing if it is less?

    Code:
    <?php echo substr($row['adtitle'], 0, 60); ?>
    Thank you.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,935
    Thanks
    16
    Thanked 303 Times in 302 Posts
    Blog Entries
    11

    Default

    Something like;
    Code:
    $title = $row['adtitle'];
    if (strlen($title) > 60) {
    	$title = substr($title, 0, 60).'...';
    }
    echo $title;
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    qwikad.com (05-17-2013)

  4. #3
    Join Date
    Oct 2012
    Posts
    147
    Thanks
    18
    Thanked 1 Time in 1 Post

    Default

    Thank you. It's what I needed!

Similar Threads

  1. putting white box around images...
    By justinchrono in forum HTML
    Replies: 4
    Last Post: 03-09-2010, 09:08 PM
  2. Replies: 2
    Last Post: 04-19-2009, 10:46 PM
  3. <title></title> location
    By afe in forum HTML
    Replies: 36
    Last Post: 01-09-2008, 12:32 AM
  4. <title></title> in header
    By dz67 in forum ASP
    Replies: 8
    Last Post: 01-08-2008, 12:57 PM
  5. Title Time Script (little question)
    By nycguurl in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 12-02-2007, 01:48 AM

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
  •