$plain_css
変数にいくつかの CSS があるとします。
.slide-pause {
cursor: url(http://example.com/img/bg/pause.png),url(http://example.com/img/bg/pause.png),auto;
}
.something {
background-image: url('http://example.com/img/bg/beautiful.png'); // We have Quotes here
}
この CSS からすべての URL を取得する必要があります。
これは私がこれを達成しようとしている方法です:
preg_match_all('!url\(\'?http://example.com/.*\)!', $plain_css, $matches);
$matches
返されるもの:
array
0 =>
array
0 => string 'url(http://example.com/img/bg/pause.png),url(http://localhost/site/img/bg/pause.png)'
1 => string 'url(http://example.com/img/bg/beautiful.png)'
返す必要があるもの:
array
0 => string 'url(http://example.com/img/bg/pause.png)'
1 => string 'url(http://example.com/img/bg/pause.png)'
2 => string 'url(http://example.com/img/bg/beautiful.png)'