0

I was changing css file urls like str_replace('url(', 'url(somelocation/', $content); now I want to exclude, absolute path ones, like url(/ does any one suggest something?

2
  • What's the problem with regular expressions? Commented Nov 8, 2010 at 21:57
  • I dont want to mess something that I can solve with a simple expression. Commented Nov 8, 2010 at 22:08

2 Answers 2

1
preg_replace('@url\(([^/].*)\)$@', preg_quote($location) . '$1', $content);
Sign up to request clarification or add additional context in comments.

Comments

0
$location = 'somelocation'; // or however you're getting somelocation
if (strpos($location, '/') === 0) {
    $location = substr($location, 1);
}
str_replace('url(', 'url(' . $location, $content);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.