一聚教程网:一个值得你收藏的教程网站

热门教程

PHP 替换字符串中img标签样式 preg_match_all str_replace

时间:2022-06-25 02:42:07 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

function repalceTA($str){
    preg_match_all("/]+>/isU" class="js-smartPhoto-pc" target="_blank">]+>/isU", $str, $arr);
    for($i=0,$j=count($arr[0]); $i<$j; $i++){
        $str = str_replace($arr[0][$i],"",$str);
    }
    return $str;
}

php中preg_match_all函数

preg_match_all — 执行一个全局正则表达式匹配

int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG_PATTERN_ORDER [, int $offset = 0 ]]] )

搜索subject中所有匹配pattern给定正则表达式 的匹配结果并且将它们以flag指定顺序输出到matches中.

在第一个匹配找到后, 子序列继续从最后一次匹配位置搜索.


php中str_replace函数

定义和用法

str_replace() 函数使用一个字符串替换字符串中的另一些字符。

语法

str_replace(find,replace,string,count)

热门栏目