2011-12-16 76 views
1

我有一些內容是這樣的外部網頁:的file_get_contents和編碼

<script> 
str = "hello"; 
fun('\202' + str + '\203\303\287'); 
</script> 

在我的PHP頁面,我試圖檢索(的一部分)的fun()以下列方式參數:

$html=file_get_contents("webpage.html"); 
$regex_pattern = "/fun\(\'(.*)\'(.*)\'(.*)\'\)/"; 
preg_match_all($regex_pattern,$html,$matches); 

$p1=$matches[1][0]; 
$p2=$matches[3][0]; 

echo "p1: ".$p1.", length: ".strlen($p1)."<br>"; 

我得到的是$ p1等於\ 202,長度爲4.但是,我想檢索與\ 202相關的字符(並且對於由$ p2表示的字符序列也是相同的) 。

我瀏覽了與類似問題相關的問題,但我無法使用所提出的解決方案進行工作。

任何提示?

感謝

回答