Jump to content

Archived

This topic is now archived and is closed to further replies.

smithaa02

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

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?

Share this post


Link to post
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' ?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.