php将图片本地化代码示例
注明:本网站来至www.php186.com
<?php
set_time_limit(0);
$styleFileContent = file_get_contents('article.css');
//note 匹配出需要下载的URL地址
preg_match_all("/url\((.*)\)/", $styleFileContent, $imagesURLArray);
$imagesURLArray = array_unique($imagesURLArray[1]);
foreach($imagesURLArray as $imagesURL) {
$imagesURL = 'http://www.php186.com'.str_replace('"','',$imagesURL);
file_put_contents('img/'.basename($imagesURL), file_get_contents($imagesURL));
}
注明:本网站来至www.php186.com
<?php
set_time_limit(0);
$styleFileContent = file_get_contents('article.css');
//note 匹配出需要下载的URL地址
preg_match_all("/url\((.*)\)/", $styleFileContent, $imagesURLArray);
$imagesURLArray = array_unique($imagesURLArray[1]);
foreach($imagesURLArray as $imagesURL) {
$imagesURL = 'http://www.php186.com'.str_replace('"','',$imagesURL);
file_put_contents('img/'.basename($imagesURL), file_get_contents($imagesURL));
}