|
Posted by Vincent Delporte on 06/13/06 22:34
Hello
I need to extract multiple occurends of the same type of item from a
web page. The part I need looks like
"id=123456"
.... without the quotes, and add each found item into an associative
array stuff[$code] by adding a comma and the new item.
I'm not used to using regexes with PHP (5, FWIW), and am a bit lost at
how to do this. Should I use eregi()? preg_match_all? Something else?
And how to do this?
Here's the code:
----------------
$stuff = file_get_contents("http://localhost/stuff.html");
if(eregi("Nothing found.",$stuff)) {
echo "Nothing found.";
} else {
if (eregi("id=[0-9]+",$stuff)) {
preg_match_all ("|id=(\d+)|", $stuff, $out,
PREG_PATTERN_ORDER);
//How to extract item from $out[]?
stuff[$code] = stuff[$code] . "," . $out[1][1];
}
}
----------------
Thank you!
[Back to original message]
|