Situation
I want to use preg_replace() to add the number '8' after each of [aeiou] .
Example
from
abcdefghij
to
a8bcde8fghi8j
Question
How to write a replacement string?
// input string $in = 'abcdefghij'; // this obviously won't work ----------↓ $out = preg_replace( '/([aeiou])/', '\18', $in);
This is just an example , so the str_replace() is not a valid answer.
I want to know how to have the number after the backlink in the replacement string.
php regex escaping backreference
Mightypork
source share