Home > Backend Development > PHP Tutorial > Code to download images in CSS files using PHP_PHP tutorial

Code to download images in CSS files using PHP_PHP tutorial

WBOY
Release: 2016-07-21 16:13:03
Original
907 people have browsed it

Share a piece of code that uses PHP to download images in CSS files

Copy the code The code is as follows:

//note Set PHP timeout
set_time_limit(0);

//note Get style file content
$styleFileContent = file_get_contents('images/style.css');

//note Match the URL address that needs to be downloaded
preg_match_all("/url((.*))/", $styleFileContent, $imagesURLArray);

//note Loop the address that needs to be downloaded , download one by one
$imagesURLArray = array_unique($imagesURLArray[1]);
foreach ($imagesURLArray as $imagesURL) {
file_put_contents(basename($imagesURL), file_get_contents($imagesURL));
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313579.htmlTechArticleShare a piece of code that uses PHP to download images in CSS files. Copy the code as follows: ?php //note Set up PHP Timeout set_time_limit(0); //note Get the style file content $styleFileC...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template