使用PHP下载CSS文件中的图片的代码
2013-10-08 06:57
573 查看
共享一段使用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));
}
?>
复制代码代码如下:
<?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));
}
?>
相关文章推荐
- CSS 学习笔记(1)
- Mozilla推荐的CSS书写顺序
- Chrome浏览器下CSS字体大小设置小于12px无效问题
- CSS里的 no-repeat 是什么意思
- css选择器的性能
- 推荐大家使用的CSS书写规范及顺序
- 制作变形、移位、扭曲等效果:《CSS3 transform》
- CSS样式的基础学习总结
- html和css基础超过范围的变成省略号
- 收藏几款不错的CSS3特效
- 智能选择器和语义化的CSS
- JSP标签、正则、CSS选择器 学习笔记
- CSS里的 no-repeat 是什么意思
- 【使用CSS工具清理无用的样式】
- CSS 三栏自适应布局
- 自定义TabHost,TabWidget样式 .
- Css gray 无法覆盖IE10
- PHP下载CSS文件中图片的代码
- 捣鼓捣鼓css3动画。。。。
- CSS