2014-10-29 37 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

相关问题