提供一个常见的php下载css中图片代码,有需要的朋友可以下载,只要把$url填写好就行了哈。
代码如下 |
复制代码 |
<?php教程 $url = 'http://www.phprm.com'; $data = file_get_contents('abc.css教程'); preg_match('/(.*//.*?)//',$url,$host); $host = $host[1]; if (!is_dir('img')) { mkdir('img'); } $regex = '/url('http://pic2.phprm.com/2011/09/26/{0,1}"{0,1}(.jpg)/'; preg_match_all($regex,$data,$result); foreach ($result[1] as $val) { if (preg_match('/^http.*/',$val)) { $target = $val; } else if (preg_match('/^/.*/',$val)) { $target=$host.$val; } else { $target=$url.$val; } echo $target."<br/>rn"; preg_match('/.*/(.*.D+)$/',$val,$name); if (!is_file('./img/'.$name[1])) { copy($target,'./img/'.$name[1]); } }?> |
本文地址:http://www.phprm.com/code/40037.html
转载随意,但请附上文章地址:-)