Skip to content
Advertisement

Tag: str-replace

php str_replace replacing itself

I need to replace every occurrence of one of the letters a,o,i,e,u with [aoieu]? I tried to do the following: But when giving it input of black instead of giving me the expected bl[aoieu]?ck it gave me How can I get it to not replace things it already replaced? Answer You can consider using a regular expression for this, or

Replace string in an array with PHP

How can I replace a sub string with some other string for all items of an array in PHP? I don’t want to use a loop to do it. Is there a predefined function in PHP that does exactly that? How can I do that on keys of array? Answer But array_map is just a hidden loop. Why not use

Advertisement