怎样替换css文件中相应的内容?
test.css 中的代码如下:-------------------------------------------------------------
a{color:A1}
button{background-color:A2}
.test{border:A3}
-------------------------------------------------------------php中的代码:
-------------------------------------------------------------
<?php
$css_var = array("#ff0000","green","1px solid gray");
// 怎么将上面的test.css文件中的A1,A2,A3替换成上面$css_var中对应的值?
?>
-------------------------------------------------------------
test.css 中的代码如下:-------------------------------------------------------------
a{color:A1}
button{background-color:A2}
.test{border:A3}
-------------------------------------------------------------php中的代码:
-------------------------------------------------------------
<?php
$css_var = array("#ff0000","green","1px solid gray");
// 怎么将上面的test.css文件中的A1,A2,A3替换成上面$css_var中对应的值?
?>
-------------------------------------------------------------
$css_var = array("#ff0000","green","1px solid gray"); $s = file_get_contents('test.css');$s = preg_replace($p, $css_var, $s);file_put_contents('test.css', $s);