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

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

WBOY
Release: 2016-06-13 13:49:14
Original
915 people have browsed it

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

12345
abcde


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

但是

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




------解决方案--------------------
$r = '#
]*>(.*)
#U';
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template