Home  >  Article  >  Backend Development  >  正则表达式取html里的内容如何取之二

正则表达式取html里的内容如何取之二

WBOY
WBOYOriginal
2016-06-13 13:49:14857browse

正则表达式取html里的内容怎么取之二

12345
abcde


$s = '
12345
abcde
';
$r = '#
]*>(.*)
#';
preg_match($r, $s, $a);
echo $a[1];
上一个问题有高手帮忙解决了,
这样可以取出第一个div里的12345
abcde

但是

如果想取出 12345
abcde 即:第一个开始div和第一个结束/div之间的内容,该如何取




------解决方案--------------------
$r = '#
]*>(.*)
#U';
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