How can I remove the first instance of a certain piece of html from a string.
I’m looking to remove
</tr>
</table></td>
</tr
which is near the begining, but it also appears throughout the string.
I also need a way to do the same thing but the last instance of it.
Anyone know?
if you know roughly how close to the end of the string the substring that you want to replace is, you use
substr_replace()with a negative$startand$lengthparameters, or you could just code up a function by hand to actually go through, find the last occurrence, then delete it. something like this (untested, written very quickly):similar, for first occurrence
you could also generalize this to replace the nth occurrence: