php str_replace() function
Translation results:
UK[rɪˈpleɪs] US[rɪˈples]
vt.Replace; replace; put... back into its original place; (with...) replace
Third person singular: replaces Present participle: replacing Past tense: replaced Past participle: replaced
php str_replace() functionsyntax
Function:String replacement operation, case sensitive
Syntax: str_replace(find,replace,string,count)
Parameters:
Parameters | Description |
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. Variable counting the number of substitutions. |
Description: Replace some characters in the string with other characters (case sensitive). 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 every element in the array. If both an array search and a replace are required, and the number of elements to be replaced is less than the number of elements found, the excess elements will be replaced with an empty string. If you are looking for an array and replacing a string, then the replacement string will work for all found values.
php str_replace() functionexample
<?php echo str_replace("world","php.cn","Hello world!"); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Hello php.cn!
<?php $i = "i like JavaScript"; echo str_replace("JavaScript","php",$i); ?>
Run Instance»
Click the "Run Instance" button to view the online instance
Output:
i like php