Home > Article > Backend Development > How to use str_ireplace function in php
Usage of str_ireplace function in php: [str_ireplace(find,replace,string,count)]. The str_ireplace function is used to replace some characters in a string (case-insensitive).
php The str_ireplace function is used for string replacement operations. It is not case-sensitive. Its syntax is str_ireplace(find,replace,string,count). The parameter find is required and specifies the value to be found; replace is required and specifies the value to replace the value in find; string is required and specifies the string to be searched.
(Recommended tutorial: php video tutorial)
How to use php str_ireplace function?
php str_ireplace() function syntax
Function: String replacement operation, case-insensitive.
Syntax:
str_ireplace(find,replace,string,count)
Parameters:
find Required. Specifies the value to look for.
replace Required. Specifies the value to replace the value in find.
string Required. Specifies the string to be searched for.
count Optional. A variable counting the number of substitutions.
Description:
Replace some characters in the string (not case sensitive). The function must follow the following rules: If the searched string is an array, then it will return an array. If the string being searched is an array, then it will find and replace each element in the array.
If you need to search and replace the array at the same time, and the elements that need to be replaced are less than the number of found elements, the excess elements will be replaced with empty strings. If you search an array and replace only one string, the replacement string will apply to all found values.
php str_ireplace() function usage example 1
<?php echo str_ireplace("WORLD","php.cn","Hello world!"); ?>
Output:
Hello php.cn!
php str_ireplace() function usage example 2
<?php echo str_ireplace("hello","Hi","hello php.cn!"); ?>
Output:
Hi php.cn!
The above is the detailed content of How to use str_ireplace function in php. For more information, please follow other related articles on the PHP Chinese website!