我有2个文件。一个是 test.html ,另一个是 main.php
test.html
main
main.php
中的第二个<div class=\"col-sm-5 blind-s4\">
<div class=\"blind-box \">
<img src="blob:http://example.com/aea01f28-dcd0-41c2-80fa-4f021fe9d40d" class="new-img">
</div>
</div>
在此,我想将<div class="full-html" id="full-html">
<?php include("test.html");?>
</div>
中的所有\"
替换为test.html
。
(2)我想用新图像名称
替换所有以blob开头的内容"
或
ie:blob:http://example.com/aea01f28-dcd0-41c2-80fa-4f021fe9d40d with new.img
我怎么能这样做?
答案 0 :(得分:1)
试试这个:
function replaceSlash($content) {
return str_replace('\"', '"', $content);
}
ob_start('replaceSlash');
include('test.html');
ob_end_flush();
(Credits)
答案 1 :(得分:1)
您可以使用file_get_contents
和str_replace
$myFile = file_get_contents('text.html');
$newFile = str_replace('\"', '"', $myFile);
然后你可以用echo
编写内容echo $newFile;
替换blob你应该使用regexp
str_replace(/src="blob:[^"]*/, 'src="new.img"', $newFile);