Reply to [Regex] Extracting multiple ocurrences from a page?

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация