I want to open a CSS file, search for a known classname and overwrite the old part with a new style
I have this array which contains the name of the class and the new styles
$newstyle['myclassname'][0]='color:red';
$newstyle['myclassname'][1]='another style';
$newstyle['myclassname'][2]='another style';
...
So I create a new style from this
$change=implode(';',$newstyle['myclassname']);
I work on a codeigniter project so I start to open the file
$fp = fopen($path.'myfile.css','wb');
Now I have a idea what I have to do, but I don't know the easiest way.
After open the file, I must search the ".myclassname" or "#myclassname" After that I have to delete or replace the part between {...old styles...} with the new styles which I have to create from the array.
How can I find or replace the old styles with the new ones?
Hope somebody can show me a simple way to to these steps!?
Thanks a lot.
preg_replaceis usually the better one for more complicatedstr_replace's