How to pass data from DOMDocument to regexp?
<p>Using the following code I get "img" tags from some html and check them if they are covered with "a" tags. Later if current "img" tag is not part of the "a" ( hyperlink ) I want to do cover this img tag into "a" tag adding hyperlinks start ending tag plus setting to target. For this I want the whole "img" tags html to work with. </p>

<p>Question is how can I transfer "img" tags html into regexp. I need some php variable in regexp to work with the place is marked with ??? signs.</p>

<pre><code>$doc = new DOMDocument();
$doc-&gt;loadHTML($article_header);

$imgs = $doc-&gt;getElementsByTagName('img');
foreach ($imgs as $img) {

if ($img-&gt;parentNode-&gt;tagName != "a") {

preg_match_all("|&lt;img(.*)\/&gt;|U", ??? , $matches, PREG_PATTERN_ORDER);

                                      }
                        }
</code></pre>
