css文件中图片下载方法,借助php下载css文件中的图片文件,非常简单,可以作为php入门教程学习下。
 
例子,php下载css文件中的图片的代码。
 
<?php 
//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)); 
} 
?>