Jump to content

Replace 2Nd Occurrence Of String In String..?


Recommended Posts

A combination of strpos() and subsrt_replace()The substr_replace() method has two parameters indicating the start and length of the portion to remove, and one parameter for the string to put in that location. Use strpos() to figure out the first position, then use strpos() again, using the index returned by the first one to find the second occurence. The length of the string you're searching for should be used as the length used in the substr_replace() method.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...