I got a HTML file containing:
<div>
<p class="derp">Hello</p>
<p>Hi</p>
<p>Heyo</p>
</div>
What I want to do is to do is to update the HTML file's p-tag, with specific instructions like this:
<?php
$value = "I am here to replace something!";
$index = 1;
$page_source = file_get_contents($file_name);
// Something here to replace the second p-tag with $value
file_put_contents($file_name, $page_source);
?>
I have tried 2 different methods to do this (loadHTML, preg_replace), but I want to hear your opinion on which might be the best fit in my situation.
Very greatful for answers!