Reputation: 3481
This question is related to one i posted earlier:, I have here the css file containing this code:
body {
background-image:url(images/background.gif);
color: #7a7e33;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
margin: 0px;
padding: 0px;
}
#header {
background-image:url(images/header.jpg);
width: 707px;
height:300px;
display:block;
margin-left: 240px;
padding:0px;
}
#content{
background-image:url(images/sheetmiddle.gif);
background-repeat:repeat-y;
position:relative;
}
#sheettop{
background-image:url(images/sheet.gif);
background-repeat:no-repeat;
width:707px;
}
#footer{
background-image:url(images/footer.gif);
width:707px;
height:86px;
margin-left:242px;
}
As you can see, there are many images directories. I want to add ../
so all the images directory will look like this:
background-image:url(../images/sheet.gif);
And all the other image directory.
How can I make a php code that will automatically read the style.css then insert this: ../
?
From the answer on my previous post,
$css = str_replace("url(images/", "url(../images/", $css);
What am i still missing here?
This is for my school project. Please help. Thanks!
Upvotes: 0
Views: 632
Reputation: 360782
$css = file_get_contents('/path/to/your/css/file'); // slurp in the file
$css = str_replace(...); // modify the data
file_put_contents('/path/to/your/css/file', $css); // spit it back out
Upvotes: 1