Home >Backend Development >PHP Tutorial >php正则截取解决思路

php正则截取解决思路

WBOY
WBOYOriginal
2016-06-13 10:35:51971browse

php正则截取
想要截取别人网站中的一段div,正则不太懂,截取不成功。代码如下:

$str = file_get_contents("http://cp.360.cn/jczq/?src=menu");
$preg = '/^

(.*?)/i';
preg_match($preg,$str,$match);
var_dump($match);exit;
?>

------解决方案--------------------
/
(.*?)/i
------解决方案--------------------

/
(.*?)/is

加上s
探讨

/
(.*?)/i

------解决方案--------------------
s是王道.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn