I'm actually dealing with a preg_replace to prepare a text. But I need a unique identifier for each of the replaced elements.
I'm using a manually entered identifier to be able to use it in my preg replace :
$text = preg_replace("#<anecdote=(\d+) titre=\"([^\"]+)\" texte=\"([^\"]+)\">#", '<a href="#" data-anecdote="$1" data-title="$2" data-content="$3" data-toggle="popover">?</a><span class="anecdote" id="anecdote$1">', $text);
And I would like to use something like #<anecdote titre=\"([^\"]+)\" texte=\"([^\"]+)\">#
and assign automatically an identifier, something like an int that would increment.
Is it possible to do that ?
I've tried something with the $count variable for preg replace, but I couldn't find a proper solution, so far.