php 正则应用

<?php 
$str = <<< EOT

                <a href="www/app/a/2QRN7v">
                    <div class="phonebg">
                        <img src="http://www/template9/yunqingjian/jianjie/68.jpg" >
                        <div class="phoneclick"></div>
                        <p>幸福领地</p>
                    </div>
                </a>
                <a href="www/app/a/uqARNv">
                    <div class="phonebg">
                        <img src="http://www/template9/yunqingjian/jianjie/69.jpg" >
                        <div class="phoneclick"></div>
                        <p>一世情长</p>
                    </div>
                </a>


EOT;

if(preg_match_all('%<p.*?>(.*?)</p>%si', $str, $matches)) {
   $arr[0][] = $matches[1];
}
if(preg_match_all('/src="([^<]*)" >/i', $str, $matches)) {
   $arr[1][] = $matches[1];
}
print_r($arr);
exit;

你可能感兴趣的:(php 正则应用)