Jump to content

str_replace no replacing?


LegosJedi

Recommended Posts

Okay, so I've written my own template class, but for some reason, it's not replacing any of the keys in the templates. Here's the code for the template class:

 

<?php
class template
{
var $all = array();
var $tmpl_name;

function output($filename, $existing = "", $replace = "")
{
	//global $settings;

	//$file = $settings['siteroot'].$settings['tmpl_dir'].$this->tmpl_name.$filename.".tpl";
	$file = CM_ROOT.$this->tmpl_name.$filename.".tpl";
	if(!file_exists($file))
	{
		echo '<b>Error:</b> Template file cannot be located.<br /><br />
We are trying to find <a href="'.$file.'">'.$file.'</a> in.<br />
<b>PROCESS SKIPPED.</b> <font color="red">Please notify the administrator about this problem.</font><hr />';
	}
	else
	{
		$template = file_get_contents($file);
		$template = str_replace("{".$existing[$filename]."}", $replace[$filename], $template);
		$template = str_replace("{".$this->all['existing']."}", $this->all['replace'], $template);
		echo $template;
	}
}
}
?>

 

When $existing and $replace are inputted, they're supposed to be arrays.

Link to comment
https://forums.phpfreaks.com/topic/43996-str_replace-no-replacing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.