0
<?php
$string = "http://giphy.com/static/img/homepage_banners/snl-leslie.gif";

$find_images = preg_match("/(https?:\/\/\S+\.(?:jpg|png|jpeg|gif))\s+/", $string, $matches) ? $matches[1] : "";

if(@is_array(getimagesize($find_images))) {
    // Check if image exists
    echo $find_images;
}
?>

I try to echo image link but my regex not find link of image. ??? can someone help me? thanks in advance

1 Answer 1

2

You have a \s+ at the end of the string, which will try to match one or more spaces, but your input string doesn't have any. Remove it as

/(https?:\/\/\S+\.(?:jpg|png|jpeg|gif))/

Regex Demo

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.