I want to combine those 2 preg_replace into a single one.For example replace every data-thumb-bg="
with style="background-image: url('
and after that if there is .jpg
replace it with .jpg);
.
$input = preg_replace('#data-thumb-bg="#s', 'style="background-image: url(', $input);
$input = preg_replace('#.jpg#s', '.jpg);', $input); //this must be executed only if a match has been found for above
How can i do that ?
Edit
I think i have wrongly expressed myself
The .jpg
should be replaced only if data-thumb-bg=
has been replaced.Like first you replace the data-thumb-bg
then you replace the .jpg
that follow the data-thumb-bg
Kind Regards