Replace substrings with an incremented counter value
问题 Basically what I'm looking for is the PHP version of this thread: Find, replace, and increment at each occurence of string I would like to replace the keyword following > at the start of rach line with an incrementing counter. If my input is: >num, blah, blah, blah ATCGACTGAATCGA >num, blah, blah, blah ATCGATCGATCGATCG >num, blah, blah, blah ATCGATCGATCGATCG I would like it to be... >0, blah, blah, blah ATCGACTGAATCGA >1, blah, blah, blah ATCGATCGATCGATCG >2, blah, blah, blah ATCGATCGATCGATCG