Jump to content

Converting parsed out html into array..


meister14

Recommended Posts

I have been working with simple_html_parser trying to parse out the financial tables from yahoo. I have made pretty good progress (it doesn't look like much, but it took me awhile) and I have been able to seperate it all out.

 

However, whenever I try to do an "echo $b[1];" I get an error saying "Fatal error: Cannot use object of type simple_html_dom_node as array in C:\wamp\www\test\index3.php on line 28"

 

What I would like to do is take each element (financial number) and store it in my MySql. I believe I could do that if I were able to seperate out the different numbers, I would then be able to insert them into the database.. Let me know if I could be more clear on what I am trying to do.. Thanks!

 

(the code below works)

include('simple_html_dom.php');

// get DOM from URL or file

$html = file_get_html('http://finance.yahoo.com/q/is?s=NEM&annual');

// find all table data with class "yfnc_tabledata1"

foreach($html->find('table.yfnc_tabledata1 td') as $e)

foreach($e->find('tr') as $a)

foreach($a->find('td') as $b)

echo $b.'<br />';

Link to comment
https://forums.phpfreaks.com/topic/196561-converting-parsed-out-html-into-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.