Skip to content
Advertisement

replace string php, but every change make a new variabel

i have

JavaScript

and i need to replace O with U , but not change ALL O characters.

For example

JavaScript

i used str_replace but only get $str3 , any idea?

Advertisement

Answer

It looks like you want to print the string as many times as the occurrences of O, and replace O once each time, according to the iteration number, and finally print the string with all O replaced. This will do it:

JavaScript

https://3v4l.org/ddg73

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement