【发布时间】:2012-11-02 11:02:47
【问题描述】:
我希望能够在 css 文件中搜索找到类或 id 并恢复其样式。
IE..css 文件布局
body {
margin:0;
padding:0;
}
span {
margin:0;
padding:0;
} #input { font:12px arial; }
a { color:#0000FF;
text-decoration:none;
}
.logout a:hover { text-decoration:underline; }
我想在文件中找到说 id "#input" 并将其带回样式。
font:12px arial;
或 #input{ 字体:12px arial; }
如果有更多的话,很可能会把它带回来,但要保持这个小样。
我尝试了自己,但没有运气,因为我的正则表达式不太好。
if(file_exists("css/style.css") && filesize("css/style.css") > 0){
$filesize = filesize("css/style.css");
$handle = fopen("css/style.css", "r");
$contents = fread($handle, $filesize);
fclose($handle);
}
preg_match('@^(?:#input{)?([^}]+)@i', $contents, $matches);
echo "style: {$matches[0]} <br>";
print_r($matches2);
请帮忙。
【问题讨论】:
-
它只是带回了这个身体 { margin:0;填充:0;