Answer the question
In order to leave comments, you need to log in
Parsing consecutive tags?
It was necessary to combine img tags going each other into one block, which with the help of javascript will turn into a gallery. Adding one img to the block is easy - preg_replace will work here. But how to select several consecutive tags in a separate block?
Let's say we have this code:
<font color="black"><font color="#0000ff"><</font><font color="#800000">img</font> <font color="#ff0000">src</font><font color="#0000ff">="image1.jpg"</font> <font color="#ff0000">alt</font><font color="#0000ff">=""</font> <font color="#0000ff">/></font><br/> <font color="#0000ff"><</font><font color="#800000">img</font> <font color="#ff0000">src</font><font color="#0000ff">="image2.jpg"</font> <font color="#ff0000">alt</font><font color="#0000ff">=""</font> <font color="#0000ff">/></font><br/> <font color="#0000ff"><</font><font color="#800000">img</font> <font color="#ff0000">src</font><font color="#0000ff">="image3.jpg"</font> <font color="#ff0000">alt</font><font color="#0000ff">=""</font> <font color="#0000ff">/></font><br/> <font color="#0000ff"><</font><font color="#800000">p</font><font color="#0000ff">></font>eewrwerr<font color="#0000ff"></</font><font color="#800000">p</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">div</font><font color="#0000ff">></font>qweqweqwe<font color="#0000ff"></</font><font color="#800000">div</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">img</font> <font color="#ff0000">src</font><font color="#0000ff">="image4.jpg"</font> <font color="#ff0000">alt</font><font color="#0000ff">=""</font> <font color="#0000ff">/></font><br/> <font color="#0000ff"><</font><font color="#800000">p</font><font color="#0000ff">></font>eewrwerr<font color="#0000ff"></</font><font color="#800000">p</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">img</font> <font color="#ff0000">src</font><font color="#0000ff">="image5.jpg"</font> <font color="#ff0000">alt</font><font color="#0000ff">=""</font> <font color="#0000ff">/></font><br/> <font color="#0000ff"><</font><font color="#800000">img</font> <font color="#ff0000">src</font><font color="#0000ff">="image6.jpg"</font> <font color="#ff0000">alt</font><font color="#0000ff">=""</font> <font color="#0000ff">/></font></font><br/> <br/> <font color="gray">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><font color="gray">Source Code Highlighter</font></a>.</font>
Answer the question
In order to leave comments, you need to log in
I'm not familiar with PHP's regexp features, but something like this:
((?:<img.*[^>]/>\s?){2,})Your example is being tested.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question