Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的站点从其他站点加载了一个 css 文件,其中包含以下内容:
../../1/images/pager1.png ../../2/images/pager2.png ... ../../n/images/pagern.png
我要换
../../random/images/
经过:
/images/
如何在 PHP 中执行
谢谢
试试这个 :
<?php $filename = "filename.css"; $file = file_get_contents($filename); $file = preg_replace("#\.\./.*/images/#", "/images/", $file); file_put_contents($filename, $file);