php using curl and preg_match_all [duplicate]

感情迁移 提交于 2019-12-02 07:34:48

The PHP-Error-Reporting should have given you a hint. I strongly advice to set error_reporting to E_ALL and display_errors to "on" during development.This would have given you a hint, as to why you don't get any results:

PHP Warning:  preg_match_all(): Unknown modifier 't'

So you should add an escape to the slash inside your regex, because, you use it as delimiter.

preg_match_all('/<td align=right>(\d+?)<\/td>/', $response, $matches2);

As always, I would suggest, using another delimiter and thus keep your regex more readable. I normally choose "~". This would look like:

    preg_match_all('~<td align=right>(\d+?)</td>~', $response, $matches2);

Try this:

preg_match_all('/<td align=right>(\d+?(\.\d+)?)<\/td>/', $response, $matches2);

print_r($matches2[1]);

Notice the forward slash in the closing TD tag is now escaped.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!