2013-05-12 44 views
0

我正在編寫一個用於匹配Code ussing preg匹配所有標記的php。使用preg匹配的代碼匹配全部

這裏是我的php代碼。

preg_match_all('|SentSmsId(\d*?)&noOfMessages|i', $data, $code); 

echo「$ code」;

這裏是html代碼。

<a href="sentSms.php?zxcoiesesscd=&SentSmsId=8830978&NoOfMessages=" style="text-decoration:none;" 

我想匹配sentsmsid代碼並回顯它。

但不起作用。

怎麼了?

回答

0

你缺少你的正則表達式=

preg_match_all('|SentSmsId=(\d*?)&noOfMessages|i', $data, $code); 
print_r($code); 

Working Demo.

+0

謝謝...我錯過了它... :) – 2013-05-13 10:10:17

+0

很高興幫助你:) – Rikesh 2013-05-13 10:11:10

0

你需要採取了=帳戶

例如SentSmsId \ = & noOfMessages

0

這是當你已經包含在$數據幾個代碼(\ d *):

preg_match_all('~SentSmsId=\K\d++(?=&noOfMessages)~', $data, $codes); 

print_r($codes); 

但是,如果你正在尋找僅爲1碼,你必須更好地使用的preg_match代替。