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

Ilyssis
  • 4,849
  • 7
  • 24
  • 30

2 Answers2

1
preg_match("/\((.*)\)/",  $sStr,  $matches);
print_r($matches);
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 = "";
}
simshaun
  • 21,263
  • 1
  • 57
  • 73