fork download
  1. <?php
  2. $content = <<<FIM
  3. text text text text <img src="path/to/image/1">text text text text
  4.   <img src="path/to/image/2">
  5. text text text text text text text text text text text text text text text text <img src="path/to/image/3"><img src$
  6. <img src="path/to/image/5">
  7. FIM;
  8.  
  9. $frst_image = preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $content, $matches );
  10.  
  11. print_r( $matches[1] );
Success #stdin #stdout 0.04s 52480KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => <img src="path/to/image/1">
            [1] => <img src="path/to/image/2">
            [2] => <img src="path/to/image/3">
            [3] => <img src="path/to/image/5">
        )

    [1] => Array
        (
            [0] => path/to/image/1
            [1] => path/to/image/2
            [2] => path/to/image/3
            [3] => path/to/image/5
        )

)