Ok, So I have a PHP code that grabs some HTML from a database. I have also built a way to edit it and I want to have a "Preview" button on the editor. So I want to have the comments around the php code that gets the html so when I grab the page with file_get_contents the HTML is surrounded by the comments and can be deleted and made room for the HTML that I want to preview.
Grab from database
<!--Main-->
<?php
if($snippets == 00){
include('Connections/sitemap.php');
}else{
echo $row_pagegrab['content'];
}
?>
<!--MainEnd-->
Grab new code
$pattern = '/<!--Main-->.*?<!--MainEnd-->/';
$source = file_get_contents("http://www.".$row_getUser['siteURL']."/".$row_ContentHTML['incname'].".php", 2000000000);
$content = preg_replace($pattern, $postedValue, $source);
echo $content;