Home >Backend Development >PHP Tutorial >PHP regular replacement problem
I am a regular comparison expert. Now there is a problem of regular replacement that I have been unable to solve. The demand is as follows:
tags in some content
<code><p style="dsfdsf">(这里有任意内容和标签)<img class="sdfdsf" src="tupian.jpg">( 这里也有任意内容和标签)</p> </code>
Then replace the item with this:
<code><p style="dsfdsf">(这里有任意内容和标签)( 这里也有任意内容和标签)</p><figure><img src="tupian.jpg" /></figure> </code>
To put it simply, img is wrapped with figure and then extracted and placed behind P. How to write it using preg_replace?