Jump to content

Get Image Location using Regular Epression


ajbar7

Recommended Posts

Hi Guys, Im having an issue with the following regular expression trying to pull out the thing between the src="" in an image tag here is my code any help would be hugely appreciated cheers.

 

My Code

<?

$img = "/ <img[ ]+[^>]*src[^>]*[^/].(?:jpg|bmp|gif)(?:\\\"|\') ^/";

echo $img;

 

if (preg_match($img, "<img src='bob.jpg' />")) {

    echo "A match was found.";

} else {

    echo "A match was not found.";

}

?>

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.