str_replace 批量查找替换字符串

<?php
$str = 'I Love You!';
$str = str_replace('o','O',$str,$count);
echo $str.PHP_EOL; // I LOve YOu!

echo '替换了'.$count.'个'.PHP_EOL; // 替换了2个

$str = 'I Love You!';
$str = str_replace(['o','u'],'O',$str,$count);
echo $str.PHP_EOL; // I LOve YOO!

echo '替换了'.$count.'个'.PHP_EOL; // 替换了3个

非常的实用,方便。

posted @ 2019-03-13 11:01  TBHacker  阅读(4004)  评论(0编辑  收藏  举报