Use PHP to download the image code in the CSS file

Source: Internet
Author: User
The image in the CSS file has never known how to download before, but now it can be implemented simply using php. The details are as follows, if you are interested, you can refer to sharing a piece of code for downloading images in CSS files using PHP.
The code is as follows:
// Note: Set the PHP timeout.
Set_time_limit (0 );

// Note: get the style file content
$ StyleFileContent = file_get_contents ('images/style.css ');

// The note matches the URL to be downloaded.
Preg_match_all ("/url \ (. *) \)/", $ styleFileContent, $ imagesURLArray );

// Download the addresses to be downloaded in the note loop one by one
$ ImagesURLArray = array_unique ($ imagesURLArray [1]);
Foreach ($ imagesURLArray as $ imagesURL ){
File_put_contents (basename ($ imagesURL), file_get_contents ($ imagesURL ));
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.