2014-10-29 41 views

回答

0

要獲取文件的內容,您需要使用php'sget_file_contents function =>get_file_contents

獲取文件的內容後,您需要使用preg_match_all =>preg_match_all 來匹配定義模式的所有出現。

然後使用foreach loop =>foreach來遍歷匹配並分別返回每個值。

這裏是全碼=>

$str = file_get_contents("path to the file"); 

preg_match_all('/\b[\w\.]+class12\b/',$str,$matches); 

foreach($matches as $match){ 

foreach($match as $m){ 

     echo $m.'<br>'; 

     } 

    } 

另外閱讀有關正則表達式=>Regular Expressions

相關問題