-3

i have 2 files . one is test.html ,and other is main.php

test.html

<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>    

Second in main.php

<div class="full-html" id="full-html">
            <?php include("test.html");?> 
    </div>

Here i want to replace all \" in test.html with " .

(2) I want to replace all starting with blob with new image name

  ie:blob:http://example.com/aea01f28-dcd0-41c2-80fa-4f021fe9d40d with new.img

or

blob:http://example.com/some_url   with new.img

How i can do this ?

3
  • $string = str_replace( '\"', '"', $string ); Commented Dec 31, 2017 at 10:30
  • 1
    What @halojoy means is <?php str_replace( '\"', '"', include("test.html")); ?> Commented Dec 31, 2017 at 10:32
  • I'm voting to close this question as off-topic because the question has changed from its original shape. Commented Dec 31, 2017 at 11:15

2 Answers 2

1

Try this:

function replaceSlash($content) {
  return str_replace('\"', '"', $content);
}

ob_start('replaceSlash');
include('test.html');
ob_end_flush();

(Credits)

Sign up to request clarification or add additional context in comments.

1 Comment

Please check the question now
1

You can use file_get_contents and str_replace

like that

$myFile = file_get_contents('text.html');
$newFile = str_replace('\"', '"', $myFile);

And then you can write the content with echo

echo $newFile;

Update

for replacing blob you should use regexp

str_replace(/src="blob:[^"]*/, 'src="new.img"', $newFile);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.