Thursday, 15 September 2011

dom - Read from behind of 2 identicall meta tags using PHP -



dom - Read from behind of 2 identicall <span> meta tags using PHP -

all want read external source 2 prices, minimum cost , maximum one.

this external source:

<p class="mb_05 magnify_price_stores"><span> <span class="txt_price_gray">429,11 ron</span> - <span class="txt_price_gray">678,50 ron</span> </span> <span><span class="gray">(de la <b>50</b> magazine)</span></span></p>

i using code:

function emag() { $dom1 = file_get_html("http://www.shopmania.ro/telefoane-mobile/p-samsung-galaxy-y-duos-s6102-25140344"); foreach ($dom1->find('span [class=txt_price_gray]') $node) { $result = $node->innertext; $price = explode("ron", $result); $prices[] = $price[0]; echo "$prices[0]"; }} emag()

and getting this: 429,11 429,11 on $prices[0] , 678,50 on $prices[1] $prices[0] double!

save values array iterate though them. replace the

echo "$price[0]";

with

$prices[] = $price[0];

the 2 prices can accessed $prices[0] , $prices[1]

php dom find

No comments:

Post a Comment