I’m having problems converting HTML into regular expressions.
I just can’t seem to figure it out, does anybody know of a good set of tutorials?
This is the code I need to convert:
<div class="offerbox_right">
<h2><a href="none.php" target="_blank">NEEDED/(.*?)</a></h2>
<div class="voucher_detail">
<div class="code_wrapper">
<div class="code_left">Code</div>
<span class="code" id="code" title="none.php">NEEDED/(.*?)<img class="scissors" src="none.png" alt="Image" /></span>
</div> <!-- /code_wrapper -->
<p>NEEDED/(.*?)</p>
</div>
This is the code I’m using currently and it works great, but I just can’t seem to convert it all:
if(preg_match_all("/<span\s.*?class=\"code\"[^>]+>(.*?)<img\s.*?class=\"scissors\"[^>]+>/i", $printable, $matches, PREG_SET_ORDER));
{
foreach($matches as $match){
echo("$match<br />");
}
}
Any help would be great, Thanks!
EDIT: I need to echo the 3 match’s listed above.
You should use
echo("$match<br />");instead of$match[1],because of the foreach