我从网站rss
为finde .mp3链接编写php程序 try{
$con = new SimpleXMLElement('http://www.taktarane.ir/feed',NULL,TRUE);
foreach ($con->channel->item as $items) {
$content = $items->children('content', true)->encoded;
$newReg = "/(http)(s?)(\:\/\/)(www\.)(.{5,120})(\.)(mp3|zip)/i";
preg_match_all($newReg, $content, $matches, null, 0);
print_r($matches);
}
}catch (Exception $ex){
echo $ex;
}
然而,它返回空阵列!!! 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( ) 排列 ( )
然而,我在http://regex101.com/测试它有35个匹配结果!!
答案 0 :(得分:0)
只需留下最后两个参数。参数标志不能为空,而是PREG_PATTERN_ORDER或PREG_SET_ORDER
preg_match_all($newReg, $content, $matches);