2011-12-29 57 views
0

我的HTML看起來像這樣,我得到它在PHP字符串$輸出,我需要做的是分裂,只顯示在內容中的字符串<!-- start Default Content //--> AND <!-- end Default Content //-->之間PHP:找到一個HTML標記之間的內容

<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
     <title>Multimedia Message</title> 
    </head> 
    <body leftmargin="0" topmargin="0"> 


       <tr height="15" style="border-top: 1px solid #0F7BBC;"> 
        <td> 
         <!-- start Default Content //--> 

sdf sdf 


sd fsd 
<br> </br> 
s 
df 
sd 
f 
s 
<!-- end Default Content //--> 
        </td> 
       </tr> 


    </body> 
</html> 

回答

1

一個解決辦法是使用正則表達式:

$matches = array(); 

preg_match("#<!-- start Default Content //-->(.*)<!-- end Default Content //-->#isu", $html, $matches); 

echo $matches[1]; 
+0

大ŧ帽子工作:) – user580950 2011-12-29 12:01:38

0

這應該做的伎倆

preg_match ('/Start Default Content \/\/-->.*<!-- end Default Content/',$output,$matches); 
    $string = substr($matches[0],27,-24); 
相關問題