fork download
  1. <?php
  2. // defining the input
  3. $e =
  4. '<div class="topbar-links"><div class="gravatar-wrapper-24">
  5. <img src="https://w...content-available-to-author-only...r.com/avatar" alt="" width="24" height="24" class="avatar-me js-avatar-me">
  6. </div>
  7. </div> <img test2> <img test3> <img test4>';
  8. // defining the regex
  9. $re = "/<img.*>/U";
  10. // put all matches into $matches
  11. preg_match_all($re, $e, $matches);
  12. // start creating the result
  13. $result = "<p class='images'>";
  14. // loop to get all the images
  15. for($i=0; $i<count($matches[0]); $i++) {
  16. $result .= $matches[0][$i];
  17. }
  18. // print the final result
  19. echo $result."</p>";
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
<p class='images'><img src="https://w...content-available-to-author-only...r.com/avatar" alt="" width="24" height="24" class="avatar-me js-avatar-me"><img test2><img test3><img test4></p>