Hello, how would I specify a web page, such as: www.test.com/list.php And in this page, there would be hyperlinked images. Every image has its own unique id, and is used inside the hyper as follows: http://test.com/page2.php?id=x So what I want to do, is sort through this page, saving every id into my array variable. So say the first 2 images had id's 1 & 7, like http://test.com/page2.php?id=1 http://test.com/page2.php?id=7 I need the script to run through, and gather what is after ?id= , and store it into my variable $id[x]; So I would have: $id[0] = 1; $id[1] = 7; and so on, until it gathers the id from every images hyperlink. Thanks!
I figured something out, but it doesn't loop through the source gathering every id, just the first one it finds. Here's the code, if anyone could build up on it: $start = strpos($find, 'id=', $index); if($start) { $start += 6; $index = $start; $end = strpos($find, ' ', $start); if($end) { $id = substr($find, $start, $end - $start); $index = $end; $list[$key] = $id; $key++; } } Code (markup): Thanks.
Here is something to get you started, this will get all your image links from the page ($html) into $matches... preg_match_all("/<img src=\"([^']*?)\">/", $html, $matches); print_r($matches); PHP: