This question already has an answer here:
$update_text= preg_replace("/(<a[^>]*>)\s*(.*?)\s*(<\/a>)/s", "$1
\t$2
$3", $text);
Have this :
<a href="#" class="example">
<img src="bg1.jpg">
text text
</a>
<a href="#" class="example">
text text
<img src="bg2.jpg">
text text
</a>
<a href="#" class="example">
<img src="bg3.jpg">
</a>
Want this :
<a href="#" class="example">
<img src="bg1.jpg">
text text
</a>
<a href="#" class="example">
text text
<img src="bg2.jpg">
text text
</a>
<a href="#" class="example">
<img src="bg3.jpg">
</a>
https://regex101.com/r/qo2N22/3
I want to add \t
all $2
lines but only applied to the first line. Could anyone help me? Thanks.
</div>