2016-10-15 59 views
1

返回特定的標籤我有這個在PHP搜索槽HTML內容使用PHP

$url = '<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
</head> 
<body> 
    <div class="waitmsg" id="WaitMessage" style="display:none"> 
     <WaitMessage>Transaction Processing, Please Wait...</WaitMessage> 
    </div> 
    <form id="mpiRun" action="form.php" method="post"> 
     <input type="hidden" name="dest" value="33777" /> 
     <input type="hidden" name="one" value="102900" /> 
     <br>  
     <br> 
     <noscript>  
      <center>  
       <h1>Processing Transaction</h1> 
       <input type="submit" />  
      </center> 
     </noscript> 
    </form> 
</body> 
</html>'; 

是否有使用PHP的方式,我可以得到

$result = '<form id="mpiRun" action="form.php" method="post"> 
     <input type="hidden" name="dest" value="33777" /> 
     <input type="hidden" name="one" value="102900" /> 
     <br>  
     <br> 
     <noscript>  
      <center>  
       <h1>Processing Transaction</h1> 
       <input type="submit" />  
      </center> 
     </noscript> 
    </form>'; 

如果不能使用PHP來完成,還有什麼其他方法可以實現。非常感激任何的幫助。

+0

我已更新答案。覈實。它會工作 –

回答

2

對於這個問題,這應該工作。

$start = strpos($url,"<form"); 
$end = strpos($url,"</form>"); 
$len = $end - $start; 
$result = substr($url,$start,$len); 

現在,$result包含你想要的。 查找<form></form>的開始位置,並將子字符串存儲在$result中。