2012-11-04 50 views
-6
替換CSS值

我的網站加載從其他網站的CSS文件與很多:搜索和PHP

../../1/images/pager1.png 
../../2/images/pager2.png 
... 
../../n/images/pagern.png 

我想更換

../../random/images/ 

由:

/images/ 

如何要做PHP

謝謝

+3

一個很好的文本編輯器? – AlexP

+0

str_replace()應該這樣做 – 2012-11-04 20:41:10

+0

您是否使用PHP生成CSS?你解釋它的方式,你正在複製其他網站的風格。 – Ariaan

回答

0

試試這個:

<?php 
$filename = "filename.css"; 
$file = file_get_contents($filename); 
$file = preg_replace("#\.\./.*/images/#", "/images/", $file); 
file_put_contents($filename, $file); 
+0

感謝RezaSh。這行得通。這是我需要的。非常感謝 –