Skip to content

Instantly share code, notes, and snippets.

@salipro4ever
Created September 21, 2019 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salipro4ever/56ba8ea8b03afcf9c8418bfecf870b1c to your computer and use it in GitHub Desktop.
Save salipro4ever/56ba8ea8b03afcf9c8418bfecf870b1c to your computer and use it in GitHub Desktop.
Download all image url from string
    $string = file_get_contents(config_path('mapplic.json'));

        $pattern = '~(http:|https:)\/\/[^/\s]+\/\S+\.(jpe?g|png)~i';

        $m = preg_match_all($pattern,$string,$matches);

        print_r($matches[0]);

        foreach ($matches[0] as $i => $url){

            $name = basename($url);
            file_put_contents($name, file_get_contents($url));
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment