I have looked at a couple of questions here, and done a Google search but I cannot seem to find the correct way to go about doing this.
I am using this function
function replace_c($content){
global $db;
$replacements = $db->query("SELECT * FROM `replacements`");
while($replace = $replacements->fetch_assoc()){
preg_replace("/".$replace['triggers']."/i",$replace['php'], $content);
}
return $content;
}
and this is my call to the function
$contents = replace_c(file_get_contents("templates/" . $settings['theme'] . "/header.html"));
It doesn't give an error, it just doesn't replace the text like it should so I am not sure if the function is actually working. I did try preg_replace_callback
but I don't think I fully understand how it works and was producing nothing but errors, do I have to go the callback route, or am I just missing something in my current function?