I am new to php and was having a typical problem to pull some fields from an array generated by the following php code:
$html=file_get_html("http://www.flipkart.com/books/9781846467622");
$e = $html->getElementById("mprodimg-id");
echo $e;
$f = $e->find('img');
echo $f['data-src'];
The output array f as seen after applying var_dump($f) in the code is as follows:-
Array ( [0] => simple_html_dom_node Object ( [nodetype] => 1 [tag] => img [attr] => Array ( [onerror] => img_onerror(this); [data-error-url] => http://img1a.flixcart.com/img/book.jpg [height] => 275 [width] => 275 [data-src] => http://img7a.flixcart.com/img/622/9781846467622.jpg [src] => data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP////Ly8v///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw== [onload] => lzld(this) [alt] => Buy Numbers [title] => Numbers ) [children] => Array ( ) [nodes] => Array ( )
I need to echo the value of the field "data-src". Can someone please help.
The html as seen by firebug is as follows from where i need to scrape this.
<div id="mprodimg-id" class="mprodimg">
<img width="275" height="275" title="Numbers" alt="Buy Numbers" onload="lzld(this)" src="data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP////Ly8v///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==" data-src="http://img7a.flixcart.com/img/622/9781846467622.jpg" data-error-url="http://img1a.flixcart.com/img/book.jpg" onerror="img_onerror(this);">
</div>