164-PHP 文本替换函数str_replace(五)

<?php
    $str='Hello world!';        //定义源字符串
    $search=array('Hello','world','!');        //定义将被替换的字符数组
    $replace=array('Hi','PHP','!!!');        //定义替换的字符串数组
    $res=str_replace($search,$replace,$str);        //使用函数处理字符串
    echo "{$str}替换后的效果为:<br />{$res}";
?> 

原文地址:https://www.cnblogs.com/tianpan2019/p/11037740.html