PHP下载css中的图片

//note 设置PHP超时时间
set_time_limit(0);
  
//note 取得样式文件内容
$styleFileContent = file_get_contents('images/style.css');
  
//note 匹配出需要下载的URL地址
preg_match_all("/url((.*))/", $styleFileContent, $imagesURLArray);
  
//note 循环需要下载的地址,逐个下载
$imagesURLArray = array_unique($imagesURLArray[1]);
foreach($imagesURLArray as $imagesURL) {
        file_put_contents(basename($imagesURL), file_get_contents($imagesURL));
}

Comments : 0

有问题可在下面发表评论,当然没事也可以在下面吹吹牛皮、扯扯淡!

发表评论

*


Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/blog/content/templates/Bitter/footer.php:40) in /www/wwwroot/blog/include/lib/view.php on line 23