smithaa02 Posted April 5, 2006 Share Posted April 5, 2006 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 https://forums.phpfreaks.com/topic/6664-how-do-you-use-ereg-to-obtain-multiple-results/ Share on other sites More sharing options...
redbullmarky Posted April 5, 2006 Share Posted April 5, 2006 [!--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 https://forums.phpfreaks.com/topic/6664-how-do-you-use-ereg-to-obtain-multiple-results/#findComment-24256 Share on other sites More sharing options...
smithaa02 Posted April 6, 2006 Author Share Posted April 6, 2006 [!--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 https://forums.phpfreaks.com/topic/6664-how-do-you-use-ereg-to-obtain-multiple-results/#findComment-24498 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.