In PHP, I m trying to match the first paragraph tag that is not immediately followed by an <img>
tag, and add a class to that paragraph tag.
For example, it would add a class to:
<p>Text</p>
and
<p><strong>Strong text</strong></p>
but not:
<p><img src="" /></p>
Here s what I have so far which successfully adds a class to the first paragraph tag, but it doesn t skip until it finds a paragraph tag that doesn t immediately contain an image:
preg_replace( /<p>/ , <p class="first"> , $text, 1);
Thoughts? Apologies if that doesn t make sense.