fork download
  1. <?php
  2.  
  3. $string = <<< LOL
  4. some text with image1 and another
  5. part of that contains image2
  6. yet another image3
  7. LOL;
  8.  
  9.  
  10. preg_match_all('/(image\d+)/i', $string, $matches, PREG_PATTERN_ORDER);
  11. for ($i = 0; $i < count($matches[1]); $i++) {
  12. echo $matches[1][$i]."\n";
  13. }
  14.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
image1
image2
image3