新聞中心
這里有您想知道的互聯(lián)網營銷解決方案
PHPpreg_filter():執(zhí)行一個正則表達式的搜索和替換
php preg_filter() 函數(shù)也用于執(zhí)行一個正則表達式的搜索和替換,等價于我們前面介紹的《preg_replace() 函數(shù)》,不同的是 preg_filter() 函數(shù)只返回匹配成功的結果,而 preg_replace() 返回所有結果,不管是否匹配成功。

創(chuàng)新互聯(lián),為您提供成都網站建設、成都網站制作、網站營銷推廣、網站開發(fā)設計,對服務柴油發(fā)電機等多個行業(yè)擁有豐富的網站建設及推廣經驗。創(chuàng)新互聯(lián)網站建設公司成立于2013年,提供專業(yè)網站制作報價服務,我們深知市場的競爭激烈,認真對待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發(fā)展進步,是我們永遠的責任!
關于 preg_filter() 的工作原理和參數(shù)說明請參考 preg_replace() 函數(shù)。
preg_filter() 函數(shù)的使用示例如下:
";
$arr1 = array(
'http://c.biancheng.net/php/',
'http://c.biancheng.net/java/',
'http://c.biancheng.net/python/',
'http://www.google.com/cn/',
'http://cn.bing.com/',
);
$pattern = array('/c\./','/biancheng/');
$replacement = array('www.','baidu');
print_r( preg_replace($pattern, $replacement, $arr1) );
print_r( preg_filter($pattern, $replacement, $arr1) );
?>
執(zhí)行以上程序的結果如下:
Array
(
[0] => http://www.baidu.net/php/
[1] => http://www.baidu.net/java/
[2] => http://www.baidu.net/python/
[3] => http://www.google.com/cn/
[4] => http://cn.bing.com/
)
Array
(
[0] => http://www.baidu.net/php/
[1] => http://www.baidu.net/java/
[2] => http://www.baidu.net/python/
)
文章題目:PHPpreg_filter():執(zhí)行一個正則表達式的搜索和替換
文章網址:http://m.fisionsoft.com.cn/article/dhdcego.html


咨詢
建站咨詢
