0

I have a string from css (background property):

$sStr = 'url(http://www.ser.com/styles/../img/big-logo.gif) 10px 0 no-repeat';

Now I need the url of the image file like this:

'http://www.server.de/styles/../media/visuals/big-logo.gif'

Thanks for help

2 Answers 2

1
preg_match("/\((.*)\)/",  $sStr,  $matches);
print_r($matches);
Sign up to request clarification or add additional context in comments.

Comments

0

It can be done a couple different ways, but in my opinion the easiest is regex.

if (preg_match('/url\(([^)]+)\)/i', $subject, $regs)) {
    $result = $regs[1];
} else {
    $result = "";
}

1 Comment

@Ilyssis $regs[1] is what you want in this version

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.