$mymarker = '/MARKER[0-9]{2}/';
preg_match_all($mymarker, $mycontent, $matches);
var_dump($matches);
Gives:
array(1) {
[0]=>
array(18) {
[0]=>
string(8) "MARKER00"
[1]=>
string(8) "MARKER01"
[2]=>
string(8) "MARKER02"
[3]=>
string(8) "MARKER04"
[4]=>
string(8) "MARKER05"
[5]=>
string(8) "MARKER07"
[6]=>
string(8) "MARKER09"
[7]=>
string(8) "MARKER13"
[8]=>
string(8) "MARKER13"
[9]=>
string(8) "MARKER16"
[10]=>
string(8) "MARKER15"
[11]=>
string(8) "MARKER21"
[12]=>
string(8) "MARKER31"
[13]=>
string(8) "MARKER22"
[14]=>
string(8) "MARKER24"
[15]=>
string(8) "MARKER26"
[16]=>
string(8) "MARKER80"
[17]=>
string(8) "MARKER81"
}
}
As we see, MARKER13 occurs twice. This duplicate instance can occur with MARKER05, MARKER07 and MARKER13.
The second value is needed to be updated to MARKERXX+1 so Second occurrence of:
Marker05 will have to be updated to MARKER06 Marker07 will have to be updated to MARKER08 MARKER13 will have to be updated to MARKER14.
How can we set this up in a loop, to check for dups and update the duplicate value to the next value.
Thanks