獲取所有網址:假設我們有一些CSS我們$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)'
謝謝,它的工作,關於捕獲的不錯的注意,不知道! – Hypn0tizeR