fork download
  1. <?php
  2.  
  3. $html = '<html><body><div style="rubbish" id="man">something </div><div id="otherid">blabla</div></body></html>';
  4.  
  5. preg_match_all('%(<div.*?id="man">.*?</div>)%im', $html, $result, PREG_PATTERN_ORDER);
  6. for ($i = 0; $i < count($result[1]); $i++) {
  7. echo $result[1][$i];
  8. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<div style="rubbish" id="man">something </div>