Jump to content

preg_match_all


dreamwest

Recommended Posts

$str = '<a href=\'/some_folder/some_file.jpeg\'>...</a>...<A HREF="/SOME_FOLER/SOME_FILE.JPG">...</a>...<a href="/some_folder/some_file.gif">...</a>'; // example links...
preg_match_all('#href=([\'"])([^.]+\.jpe?g)\1#i', $str, $matches);
echo '<pre>'.print_r($matches[2], true);

 

Output (via pre and print_r):

Array
(
    [0] => /some_folder/some_file.jpeg
    [1] => /SOME_FOLER/SOME_FILE.JPG
)

Link to comment
https://forums.phpfreaks.com/topic/143737-preg_match_all/#findComment-754277
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.