fork download
  1. <?php
  2.  
  3. $str = ' httpsssss://>.jpeeeeg httpsssss://>.gif';
  4.  
  5. preg_match_all('~http[s]*://[^\s]+\.(jp[e]*g|png|gif)$~i', $str, $result);
  6. var_dump($result);
  7.  
  8. preg_match_all('~http[s]*://[^\s]+\.(jp[e]*g|png|gif$)~i', $str, $result);
  9. var_dump($result);
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  array(1) {
    [0]=>
    string(17) "httpsssss://>.gif"
  }
  [1]=>
  array(1) {
    [0]=>
    string(3) "gif"
  }
}
array(2) {
  [0]=>
  array(2) {
    [0]=>
    string(21) "httpsssss://>.jpeeeeg"
    [1]=>
    string(17) "httpsssss://>.gif"
  }
  [1]=>
  array(2) {
    [0]=>
    string(7) "jpeeeeg"
    [1]=>
    string(3) "gif"
  }
}