what to do if I want to replace only the first occurrence of a word in a string.
eg: I want to change the first occurrence of heelo in a string with kiran.
input string == **"hello world i am a noob hello to all"**
output string == **"kiran world i am a noob hello to all"**
the str_replace is not working.
You could use
preg_replace. The 4th arugment of this functions allows you to set how many times a replacement should occur.If you don’t want regular expression meta-characters to be interpretted in the search string, use: