Home >Backend Development >PHP Tutorial > 如何从字符串中一次全部截取出来

如何从字符串中一次全部截取出来

WBOY
WBOYOriginal
2016-06-13 13:29:591107browse

怎么从字符串中一次全部截取出来?
一个页面,有N多DIV,但有部分DIV的class都一样。

怎么把

内容
,中的内容提取出来。

请注意,class=body的DIV不止一个。

谢谢各位了~~多谢~

------解决方案--------------------
PHP code
$str=sad;flksadj;flkd
<div class="body">bbbbbbbbbb</div>
<div class="bo">cccccccccccc</div>
<div class="body">sad;flksadj;flkd</div>
div;
preg_match_all('/<div class="body">(.*)/isU',$str,$m);
print_r($m[1]); <div class="clear">
                 
              
              
        
            </div>
</div>
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