【发布时间】:2017-09-22 19:37:53
【问题描述】:
我想使用标题中提到的函数获得多个结果,到目前为止,我只能使用 preg_match 获得唯一的值。我想获取所有结果的数组,然后将它们记录在我的数据库中。
这是我当前的代码:
$casturl = "https://www.themoviedb.org/movie/353491-the-dark-tower/cast";
$cast = file_get_contents($casturl);
preg_match_all('|<img class="profile lazyload fade" data-sizes="auto" data-src="(.*?)" data-srcset="|' , $cast , $castimg );
print_r($castimg);
当我打印我刚刚给出的结果时: Array ( [0] => Array ( [0] =>
我确保演员表包含我想要的内容。我已经尝试了很多可能性,但我一无所获:(
【问题讨论】:
-
你正在得到你的结果,但它正在打印 HTML,所以它搞砸了。尝试使用
var_dump($castimg);,你会看到。 -
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: php sql file-get-contents preg-match-all