我正在更改css文件的url,就像str_replace('url(', 'url(somelocation/', $content);
现在我想排除的那样,绝对路径的,比如url(/有人建议什么吗?
问问题
474 次
2 回答
1
preg_replace('@url\(([^/].*)\)$@', preg_quote($location) . '$1', $content);
于 2010-11-08T22:51:00.340 回答
0
$location = 'somelocation'; // or however you're getting somelocation
if (strpos($location, '/') === 0) {
$location = substr($location, 1);
}
str_replace('url(', 'url(' . $location, $content);
于 2010-11-08T22:22:25.527 回答