You could do this. (Note: This would only work if you wanted to replace the first instance not the Nth instance)
<?php
$Original_String = "This was was was there";
$Replace_String = "was";
$Replace_Position = strpos( $Original_String, $Replace_String);
$Replace_Length = strlen($Replace_String);
If($Replace_Position >= '0') {
$New_String = substr_replace($Original_String, "", $Replace_Position, $Replace_Length);
} else {
$New_String = "No instances found. String left as is.<br>".$Original_String;
}
Echo $New_String;
?>
There are two things to note, you can do an Nth replacement but as far as I know you would have to code it. You could loop through a piece of code that used the strpos function adding a argument on the end of the current position + length. Each loop would constitute an instance. The other thing to note is that it will only replace what you tell it to so if you run the above code it should result in two space. There are several ways to deal with that but I thought I would point it out.
Hope that helps,
Richard