screen
すべての画面cssスタイルシートをマージするためのカスタムライブラリを構築していますが、メディアタイプのみのスタイルシートを取得する方法がわかりません。例えば:
<!-- This should be fetched -->
<link href="http://www.domain.com/style.css" rel="stylesheet" type="text/css" />
<!-- This should be fetched -->
<link href="http://www.domain.com/ie.css" rel="stylesheet" type="text/css" />
<style type="text/css" media="all">
<!-- This should be fetched -->
@import url("http://static.php.net/www.php.net/styles/phpnet.css");
</style>
<style type="text/css" media="screen">
<!-- This should be fetched -->
@import url("http://static.php.net/www.php.net/styles/site.css");
</style>
<style type="text/css" media="print">
<!-- This should NOT be fetched since it is media type print -->
@import url("http://static.php.net/www.php.net/styles/print.css");
</style>
href
上記の文字列が与えられたので、値を抽出したいだけですurl
。どうしたらいいのかわからない。私は試しましたが:
preg_match_all("/(url\([\'\"]?)([^\"\'\)]+)([\"\']?\))/", $html, $matches);
print_r($matches);
しかし、それはそれを返しません。
それを達成するためのphpdom、xpath、またはregexを使用したソリューションはありますか?