this will replace the first () with numbers, not the last where we take the counter from, use the PREG_OFFSET_CAPTURE flag in preg_match and then a simple str_replace