What's the best way to extract links to images from CSS files with PHP?
I want 开发者_运维技巧to find all links to images from a CSS file.
E.g.
background-image: url(images/abc123.jpg);
I've found a PHP class called CSS parser but it doesn't seem to have a very large API. Is there a better CSS parser about?
I need to be able to modify the links in the file after I have extracted them too.
Thanks.
function getImageUrls($input_string) {
$matches = array();
preg_match_all('/url\((.+?)\);/i', $input_string, $matches);
return preg_replace('/url\((.+?)\);/i', '$1', $matches);
}
something like that anyways. pull the matches out and then format them to keep only the url path.
精彩评论