不言不语

您现在的位置是: 首页 >  PHP

PHP

PHP str_replace 函数详解

2022-06-01PHP
php中字符串怎么替换?,通过str_replace() 函数可以把其他字符替换字符串中的一些字符(区分大小写)。

str_replace() 函数以其他字符替换字符串中的一些字符(区分大小写)。

 

语法:

        str_replace(find,replace,string,count);

 

参数说明:

        find:必需,规定要查找的值。

        replace:必需,规定替换 find 中的值的值。

        string:必需,规定被搜索的字符串。

        count:可选,对替换数进行计数的变量。

<?php
	//把字符串 "Hello world!" 中的字符 "world" 替换为 "Shanghai"
	echo str_replace("world","Shanghai","Hello world!");	


文章评论