我正在更改css文件的URL,例如str_replace('url(', 'url(somelocation/', $content);
现在我想排除绝对路径,例如url(/有人建议吗?
preg_replace('@url\(([^/].*)\)$@', preg_quote($location) . '$1', $content);
$location = 'somelocation'; // or however you're getting somelocation
if (strpos($location, '/') === 0) {
$location = substr($location, 1);
}
str_replace('url(', 'url(' . $location, $content);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.