Search Css In Folder Using Php And Change Css Values
I'm new to php and need some help. I have a text box that a user can type in an html color code (ex:#373737). Once they hit the submit button I want find all color codes matching
Solution 1:
Here the code:-
if(isset($_REQUEST['setcolor'])){
$arr=glob("css\*.css"); //your css file's path
$colorcode=$_POST['defaultcolor'];
foreach($arr as $key=>$val){
$str=file_get_contents($val);
//$str=preg_replace('/#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?\b/',$colorcode, $str); //for replace all colour code
$str=str_replace("#379BB9", $colorcode,$str ); // for replace only desired colour code
file_put_contents($val, $str);
}
}
Post a Comment for "Search Css In Folder Using Php And Change Css Values"