Heim  >  Artikel  >  Backend-Entwicklung  >  php中如何用preg_match_all匹配字符串

php中如何用preg_match_all匹配字符串

WBOY
WBOYOriginal
2016-06-02 11:32:391199Durchsuche

php

<code> <div class="Wrapper">
<div class="colImg"><a href="http://store.shopping.yahoo.co.jp/matsunami/fcdm3.html"></a></div>
<div class="wrCol cf">
<div class="colText"></div>
<div class="colPrice"><p class="price"><em>4,603</em></p></div>
<div class="colStore"></div>
</div>
<div class="itemMatch"><a href="http://topics.shopping.yahoo.co.jp/notice/archives/post_8.html">123</a></div>
</div></code>

我想要获取

<code> <div class="Wrapper"></div></code>

里面的整个内容(包含了6个div,也可能是7个div,所以包含的div个数可能不定),即:

<code><div class="colImg"><a href="http://store.shopping.yahoo.co.jp/matsunami/fcdm3.html"></a></div>
<div class="wrCol cf">
<div class="colText"></div>
<div class="colPrice"><p class="price"><em>4,603</em></p></div>
<div class="colStore"></div>
</div>
<div class="itemMatch"><a href="http://topics.shopping.yahoo.co.jp/notice/archives/post_8.html">123</a></div></code>

如何用preg_match_all获取如上字符串,或者用其他方法来实现?

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn