Softpedia
 


SCRIPTS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Koken 0.8.2
  • ContentBox 1.5.2
  • jQPlayer 0.5.2
  • SPOILER ALERT! 0.0.2
  • jQuery Mask Plugin 0.9.0
  • Easing Slider 2.1.2
  • Btapp.js 0.2.0
  • WiiFlash 0.4.5
  • Breeze.js 1.3.3
  • TinyMCE Templates 3.0.2
  • Home > Scripts > Snippets

    Pull first x words from a string

    Download button


    Downloads: 514  Tell us about an update
    User Rating:
    Rated by:
    Good (3.6/5)
    23 user(s)
    Developer:

    Website:

    License / Price:

    Platforms:

    Databases:

    Language:

    Last Updated:

    Category:
    ScriptsForYou | More scripts
    www.scriptsforyou.net
    Freeware 

    Windows / Linux / BSD
    MySQL
    PHP
    August 28th, 2006, 12:24 GMT
    C: \ Snippets

     Read user reviews (0)  Refer to a friend  Subscribe

    Pull first x words from a string description

    Pull first x words from a string - Grabs the first x words from a string.

    Pull first x words from a string - Grabs the first x words from a string.

    Source Code

    function firstwords($str,$wordcount) {
    # Gareth (omnipotent.net) 0wnz m3.
    # Someday, I will be able to do this sort of thing when I grow up.
    $words=preg_split(''
    /([
    Warning: Unexpected character in input: '' (ASCII=92) state=1 in /home/sfy/public_html/snippets/view.php on line 32
    s.,;] )/'',$str,$wordcount 1,PREG_SPLIT_DELIM_CAPTURE
    );
    array_pop($words
    );
    return(
    implode('''',$words
    ));
    }



    TAGS:

    php snippets | pull words | php string | Pull | first | x

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM