<?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个
非常的实用,方便。