SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: create excerpt?

  1. #1
    SitePoint Evangelist Fleeters's Avatar
    Join Date
    Jul 2003
    Location
    Dumpsville
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    create excerpt?

    just a quick question.. anyone got a quick script or link for creating excerpts?
    Aaron Smith
    smithaaronlee.net

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you mean like how to show the first 50 characters of a message?

  3. #3
    SitePoint Evangelist Fleeters's Avatar
    Join Date
    Jul 2003
    Location
    Dumpsville
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    exactly.
    Aaron Smith
    smithaaronlee.net

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

    if you want a smarter version that wont cut half a word off, i took this from the user comments on php.net
    PHP Code:
    function myfragment($str$n$delim='...') {
       
    $len strlen($str);
       if (
    $len $n) {
           
    preg_match('/(.{' $n '}.*?)\b/'$str$matches);
           return 
    rtrim($matches[1]) . $delim;
       }
       else {
           return 
    $str;
       }



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
  •