<div class="quote" style=""><table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tbody><tr>
        <td width="24%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"><img src="http://www.xx.com.cn/images/upfiles/qbs/20090624153330.jpg" bgcolor="eaeaea" height="120" width="120"></a> </td>
        <td style="padding-top: 15px;" valign="top" width="76%"><a href="http://www.xx.com.cn/qbs/shop_4150.html">
<span style="font-size: 12px; color: rgb(102, 102, 102); font-weight: 100;">商家口碑:  </span></td>
      </tr>
    </tbody></table></div>
<br>sss[attachimg]1213208[/attachimg][attachimg]1213208[/attachimg][attachimg]1213208[/attachimg]<br>************************<div></div>
得到有颜色的部分

解决方案 »

  1.   


    preg_match_all("/^(.*?)(?=<br>)/",$str,$out);
    echo $out[1][0];
      

  2.   


    $str =<<<html
    <div class="quote" style=""> <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody> <tr>
            <td width="24%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> <img src="http://www.xx.com.cn/images/upfiles/qbs/20090624153330.jpg" bgcolor="eaeaea" height="120" width="120"> </a> </td>
            <td style="padding-top: 15px;" valign="top" width="76%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html">
    <span style="font-size: 12px; color: rgb(102, 102, 102); font-weight: 100;">商家口碑:  </span> </td>
          </tr>
        </tbody> </table> </div> <br>sss[attachimg]1213208[/attachimg][attachimg]1213208[/attachimg][attachimg]1213208[/attachimg] <br>************************ <div> </div>
    html;
    preg_match_all("/^(.+?)(<br>)/s",$str,$out);
    echo $out[1][0];
      

  3.   

    匹配这个div了<div class="quote" style=""> 这个div有可能没有,有就匹配,没有就取不到值
      

  4.   

    <?php$str = <<<HTML
    <div class="quote" style=""> <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
          <tbody> <tr> 
            <td width="24%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> <img src="http://www.xx.com.cn/images/upfiles/qbs/20090624153330.jpg" bgcolor="eaeaea" height="120" width="120"> </a> </td> 
            <td style="padding-top: 15px;" valign="top" width="76%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> 
    <span style="font-size: 12px; color: rgb(102, 102, 102); font-weight: 100;">商家口碑:  </span> </td> 
          </tr> 
        </tbody> </table> </div> <br>sss[attachimg]1213208[/attachimg][attachimg]1213208[/attachimg][attachimg]1213208[/attachimg] <br>************************ <div> </div>
    <div class="quote" style=""> <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
          <tbody> <tr> 
            <td width="24%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> <img src="http://www.xx.com.cn/images/upfiles/qbs/20090624153330.jpg" bgcolor="eaeaea" height="120" width="120"> </a> </td> 
            <td style="padding-top: 15px;" valign="top" width="76%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> 
    <span style="font-size: 12px; color: rgb(102, 102, 102); font-weight: 100;">商家口碑:  </span> </td> 
          </tr> 
        </tbody> </table> </div> <br>sss[attachimg]1213208[/attachimg][attachimg]1213208[/attachimg][attachimg]1213208[/attachimg] <br>************************ <div> </div>
    <div class="quote" style=""> <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
          <tbody> <tr> 
            <td width="24%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> <img src="http://www.xx.com.cn/images/upfiles/qbs/20090624153330.jpg" bgcolor="eaeaea" height="120" width="120"> </a> </td> 
            <td style="padding-top: 15px;" valign="top" width="76%"> <a href="http://www.xx.com.cn/qbs/shop_4150.html"> 
    <span style="font-size: 12px; color: rgb(102, 102, 102); font-weight: 100;">商家口碑:  </span> </td> 
          </tr> 
        </tbody> </table> </div> <br>sss[attachimg]1213208[/attachimg][attachimg]1213208[/attachimg][attachimg]1213208[/attachimg] <br>************************ <div> </div>
    HTML;echo htmlspecialchars($str);echo '<hr>';preg_match_all('/(<div[^<]*?)(<table[^`]*?table>)([^>]*?div>)/i' , $str , $ary);echo '<pre>';print_r($ary);echo "</pre>";?>