How to replace string in php: You can use str_replace() function to replace, such as [str_replace("iwind", "kiki", "i love iwind, iwind said");].
String replacement
(Recommended tutorial:php video tutorial)
str_replace("iwind", "kiki", "i love iwind, iwind said");
will output "i love kiki, kiki said"
Grammar:
str_replace(find,replace,string,count)
Parameter introduction:
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.
String deletion
$string = 'fdjborsnabcdtghrjosthabcrgrjtabc'; $string = preg_replace('/[abc]+/i','',$string);
Related recommendations:php training
The above is the detailed content of How to perform string replacement in php. For more information, please follow other related articles on the PHP Chinese website!