SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: substring_index

  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    substring_index

    Does using this in a query:
    PHP Code:
    substring_index(content' '75
    pull the first 75 characters or words out of the content field?

    Sketch
    Aaron Brazell
    Technosailor



  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not quite...That 'Return the substring from a string before count occurances of the delimiter'. It 'should' return everything before 75 'spaces' into the string.

    At least that is how I read it. In fact I just played with it for the first time. It should work if the spaces are all correct...if you were trying to setup a blurb section you could insert a special delimiter in yourself and end it there.

    substring_index(content,"<!-- End Blurb -->",1)

    or You could always use substring

    substring(content,0,75)

    Although this could cause unsightly 'half' words.
    Last edited by Maelstrom; May 13, 2002 at 20:41.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to fix my code...

    substring_index(content,"<!-- End Blurb -->",0)

    I realized I made the mistake when I logged off.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


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
  •