PHP Simple HTML DOM Parser finding specific text -


trying data poorly created html format

http://www.weather.gov.sg/lws/zoneinfo.do 

all need data 3 places, e.g. bedok, city , katong. how store data in array this?

this did store first 5 lines, not want.

$row_counter='0'; while($row_counter<5) { $ret['name'][] = $html->find('.form1', $row_counter)->innertext; $ret['area'][] = $html->find('.form1', $row_counter)->next_sibling()->innertext; $ret['alert'][] = $html->find('.form1', $row_counter)->next_sibling()->next_sibling()->innertext; $ret['from'][] = $html->find('.form1', $row_counter)->next_sibling()->next_sibling()->next_sibling()->innertext; $ret['till'][] = $html->find('.form1', $row_counter)->next_sibling()->next_sibling()->next_sibling()->next_sibling()->innertext; $row_counter++; } 

i able store data whole row , columns. efficient way search name, e.g. bedok , getting columns beside next_sibling?

thanks.

isn't easy. try things first ask. (:

<?php include 'simple_html_dom.php'; $html = file_get_html('http://www.weather.gov.sg/lws/zoneinfo.do');  $n = 0; $table = $html->find('table',3)->find('table',0)->find('table',0)->find('table',0)->find('table',3)->find('table',0);  $i = -3; $rows = $table->find('tr'); $holder = array();  foreach($rows $element){     $i++;     if($i < 0) continue;      $holder[$i]['name'] = $element->find('td',0)->plaintext;     $holder[$i]['zone_or_school'] = $element->find('td',1)->plaintext;     $holder[$i]['risk'] = $element->find('td',2)->plaintext;     $holder[$i]['from'] = $element->find('td',3)->plaintext;     $holder[$i]['till'] = $element->find('td',4)->plaintext; }  var_dump($holder); ?> 

if want particular data can filter out:

foreach($holder $key => $val) { if($holder[$key]['name']=='bedoc') $my_data = $holder[$key]; } 

this code isn't debuged cause on mobile now. maybe have idea if not works.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -