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);

输出一样

大批 ( )

我犯错的地方

见人,

实际上我想从这个URL获取确切的细节

我想从此 URL 中选择此详细信息

08:35 9W5048 TORONTO EXPECTED 1358 Terminal 三

所以我尝试了这个片段,但它抛出了像这样的错误

这是我的片段

$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=bde213javaxdefaca17ef63543 .portlet.prp_bde211e38117ef94303fde9faca12635_flightRoute=&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightNumber=9W5048&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightTerminal "=); //回显 $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]);

我得到了像这样的错误

注意:未定义的偏移量:第 6 行 E:\wamp\www\plugin\read-airport-arraiwals.php 中的 0

注意:未定义的偏移量:第 8 行 E:\wamp\www\plugin\read-airport-arraiwals.php 中的 0
4

1 回答 1

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);

您将获得所需的数据。快速回答,因为我没有时间为此创建一个模式,但是这个可以完成这项工作。

于 2010-07-12T13:23:26.613 回答