1
preg_match_all('|<table cellspacing="0" cellpadding="0" summary="Flight Timetable search results" id="timeTable">(.*?)</table>|', $read, $foo, PREG_SET_ORDER);
print_r($foo);

output as just

Array ( )

Where i made mistake

See guys ,

Actually i want to grab the exact details from this URL

i want to pick this details from this URL

08:35 9W5048 TORONTO EXPECTED 1358 Terminal three

So i tried this snippet , but it throwing Error like

this is my snippet

$read = file_get_contents("http://www.heathrowairport.com/portal/site/heathrow/template.PAGE/menuitem.a43f3a72926ca3b1b0c52a499328c1a0/?javax.portlet.begCacheTok=token&javax.portlet.endCacheTok=token&javax.portlet.tpst=bde211e38117ef94303fde9faca12635&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightRoute=&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightNumber=9W5048&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightTerminal="); //echo $read; preg_match_all('/(.?)</table>/si', $read, $foo, PREG_SET_ORDER); $read1 = $foo[0][0]; preg_match_all('/(.?)</tbody>/si', $read1, $foo1, PREG_SET_ORDER); print_r($foo1[0][0]);

I got Error like

Notice: Undefined offset: 0 in E:\wamp\www\plugin\read-airport-arraiwals.php on line 6

Notice: Undefined offset: 0 in E:\wamp\www\plugin\read-airport-arraiwals.php on line 8
hakre
  • 193,403
  • 52
  • 435
  • 836
Bharanikumar
  • 25,457
  • 50
  • 131
  • 201
  • 2
    Regex is not a good way to process html. Use a parser instead – John La Rooy Jul 12 '10 at 11:17
  • 1
    Your question [Fetch Details From XML Tag](http://stackoverflow.com/questions/3219030/fetch-details-from-xml-tag) should contain all the information you need to extract the wanted data. Regex aint for HTML. – Gordon Jul 12 '10 at 11:19
  • 1
    Obligatory warning: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags#1732454 – cHao Jul 12 '10 at 11:19
  • possible duplicate of [Getting content of a div (including child tags) with DOM](http://stackoverflow.com/questions/1791842/getting-content-of-a-div-including-child-tags-with-dom) – Gordon Jul 12 '10 at 11:26
  • @Bharanikumar Of course it is. It is an XHTML page, which makes it an XML application. But even if it was an HTML page, which is loosely derived from SGML, it would be parseable with DOM or XMLReader, etc. – Gordon Jul 12 '10 at 17:08

1 Answers1

1
preg_match_all('/timeTable" .*<tbody>(.*?)<\/table>/smU', $read, $foo, PREG_SET_ORDER);
preg_match_all('/<(th|td).*>(.*)<\/(th|td)>/smU', $foo[0][1], $result, PREG_SET_ORDER);
print_r($result);

And you will get the required data. Quick answer because I don't have time to create a single pattern for that, but this one will do the job.

Narcis Radu
  • 2,519
  • 22
  • 33