您的位置:首页 > Web前端 > CSS

PHP下载CSS文件中的图片

2014-09-25 17:09 302 查看
< ?php  

/*  

Documentation: 下载样式文件中的图片,水水专用扒皮工具  

*/  

//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));  

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: