2012-08-22 71 views
0

有人可以告诉我为什么这不会工作?preg_match_all():编译失败:没有重复的偏移量203 runescape

我收到错误 “preg_match_all():编译失败:没有重复的偏移203”

$html = file_get_contents('http://services.runescape.com/m=itemdb_rs/results.ws?query='.urlencode($term).'&price='.$pricerange.'&members='.$members); 
$html = str_replace(array("\r","\n"), "", $html); 
$regexp = '#<tr data-item-id="(.*?)"><td class="(.*?)"><img src="(.*?)" alt="(.*?)"><a href="(.*?)">(.*?)</a></td><td><img src="(.*?)" alt="(.*?)" title="(.*?)"></td><td class="(.*?)">(.*?)</td><td class="(.*?)">(.?*)</td></tr>#'; 
preg_match_all($regexp, $html, $matches); 
print_r($matches); 

示例URL会在的file_get_contents

http://services.runescape.com/m=itemdb_rs/results.ws?query=gold%20bar&price=all&members=no 

感谢您使用:)

+2

你能提供的完整网址是'file_get_contents'内的个例?没有它,我们无法帮助你。 – j0k

+0

我建议使用[DOM](http://ar2.php.net/manual/en/book.dom.php)而不是正则表达式。它更可靠。 – Leri

+0

已经为file_get_contents添加了一个完整的URL示例:) –

回答

0

我建议你的错误就在这里:

<td class="(.*?)">(.?*)</td></tr># 

更换由

<td class="(.*?)">(.*?)</td></tr># 
+0

非常感谢你,我不能相信我错过了这个错误,我现在感到非常愚蠢,但是谢谢你帮助我:) –

相关问题