remove words in php string
September 6th, 2009 |
|
0 Comments »
Question:
Hi E’s, I want remove words in the $string.
The variable $remove can contain one or more words, and I want remove that words from $string, like:
$remove = “remove words string”;
$string = “in php i want remove words in the string is a good idea remove for a great result”;
The return:
$string = “in php i want in the is a good idea for a great result”;
Regards, JC
Solution:
str_replace() can use an array as input, so the solution from rcflyr could be simplified into this:
1: $string = str_replace(explode(" ",$remove),"",$string);













Comments (0)
Trackbacks - Pingbacks (0)
Leave a Reply