What I would like is to replace every occurrence of a string with another string followed by a number which increments after each string found.
So if I was trying to find "href" I would want it to replace each one like the following:
first occurrence: href1
second occurrence: href2
third occurrence: hre3
So I have tried this:
$i=0;
$comments = str_replace("href", "href".++$i."", $comments);
But it doesn't work.
How would I go about doing this?