SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Quick Question

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Location
    USA
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm. I forgot so I'll ask it here.

    How do I fetch everything between 2 tags?

    Say I have a variable with [title]titlehere[/title][body]body here[/body] in it
    How do I fetch only everything between the title tags?

    thanks
    Living the OO way.
    Hardware Help | Desperados!

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this reg. exp is good enough:

    $pat="\[tag\](.*)\[/tag\]";
    ereg($pat,$input,$match);

    everything between is stored in: $match[1]
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Location
    USA
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok
    i think i understand
    but what is the input var?
    Living the OO way.
    Hardware Help | Desperados!

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be the whole string like:

    $input = "fdsfjkhds[tag]wo s348723 word[/tag]djfkhsfjds";
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Location
    USA
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks
    Living the OO way.
    Hardware Help | Desperados!


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
  •