Hi all , I need to replace a sunstring with another from a string , how to do..? I have the both the initial position and the ending position of the substring , with these input i have to do that..? Or i have, the starting of the String and the ending position.. To make it more clear.. $str = 'First Computer is ABC, you know it'; $substr = 'is'; i want to replace 'is ABC ' with 'was XYZ' ? Also i know , after ABC , a comma comes, so that i can take that position also, In sshort , the start and end pos of a sub string i know , i have to replace.. Please help me
You can use str_replace: $str = 'First Computer is ABC, you know it'; $find = "is ABC"; $replace = "was XYZ"; echo str_replace($find, $replace, $str); PHP: Hope this helps, Jay
normally the first solution (using the str_replace) will work with charm..it will search the substring itself without knowing the position...good luck.