Home >Backend Development >PHP Tutorial >PHP regular replacement problem

PHP regular replacement problem

WBOY
WBOYOriginal
2016-09-27 14:04:39918browse

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?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn