Re: Picking a phrase out of a web page.

From: Date: Fri, 09 May 2003 17:53:02 +0000
Subject: Re: Picking a phrase out of a web page.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147051@lists.php.net to get a copy of this message
Daniel, I think a regular expression would be easiest. See if this helps: <?php $lines = file("http://www.amazon.com/exec/obidos/tg/detail/-/1565926102/qid=1052500972"); foreach($lines as $line_num => $line) { if(preg_match("/\<b class=price\>(.*?)\<\/b\>/",$line,$val)) $price = $val[1]; else if(preg_match("/Amazon\.com: Books: (.*)/",$line,$val)) $title = $val[1]; } echo "$title costs $price"; ?> Output: "Programming PHP costs $27.97" Joseph

« previous php.general (#147051) next »