Jump to content

How do you use ereg() to obtain multiple results?


smithaa02

Recommended Posts

I need to find all id's inserted into a collection of html files and am wondering how to do it. For example, my files may contain:

<a href='/display.php?id=[b]44[/b]'>link 1</a> ...html stuff... <a href='/display.php?id=[b]1101[/b]'>link 1</a> ...html stuff... <a href='/display.php?id=[b]999[/b]'>link 1</a>etc...

What I would hope to get as a result would be 44,1101,999.

I use the key [i]display\.php\?id=([^"]+)"[/i] with ereg(), but I only get the first result. How would I get all the id's for each html file?
Link to comment
Share on other sites

[!--quoteo(post=361980:date=Apr 5 2006, 05:18 PM:name=smithaa02)--][div class=\'quotetop\']QUOTE(smithaa02 @ Apr 5 2006, 05:18 PM) [snapback]361980[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I need to find all id's inserted into a collection of html files and am wondering how to do it. For example, my files may contain:

<a href='/display.php?id=[b]44[/b]'>link 1</a> ...html stuff... <a href='/display.php?id=[b]1101[/b]'>link 1</a> ...html stuff... <a href='/display.php?id=[b]999[/b]'>link 1</a>etc...

What I would hope to get as a result would be 44,1101,999.

I use the key [i]display\.php\?id=([^"]+)"[/i] with ereg(), but I only get the first result. How would I get all the id's for each html file?
[/quote]

have you tried 'preg_match_all' ?
Link to comment
Share on other sites

[!--quoteo(post=362016:date=Apr 5 2006, 01:52 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 5 2006, 01:52 PM) [snapback]362016[/snapback][/div][div class=\'quotemain\'][!--quotec--]
have you tried 'preg_match_all' ?
[/quote]Thanks...that should do the trick.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.