Potrzebuję pomocy odnośnie preg_replace i array. Tworzę małą klasę do szablonów tpl i mam taki oto kod
Kod
$fp = fopen($this -> tpl_dir."/".$file, "r");
$dane = fread($fp, filesize($this -> tpl_dir."/".$file));
fclose($fp);
$dane = preg_replace("/{(.*?)}/", "<?php echo '".$this -> varibles['\\1']."'; ?>", $dane);
$file2 = md5(time()).".".$file;
$this -> cached_file = $file2.".php";
$fp = fopen($this -> tpl_dir."/cache/".$this -> cached_file, "w");
fputs($fp, $dane);
fclose($fp);
$dane = fread($fp, filesize($this -> tpl_dir."/".$file));
fclose($fp);
$dane = preg_replace("/{(.*?)}/", "<?php echo '".$this -> varibles['\\1']."'; ?>", $dane);
$file2 = md5(time()).".".$file;
$this -> cached_file = $file2.".php";
$fp = fopen($this -> tpl_dir."/cache/".$this -> cached_file, "w");
fputs($fp, $dane);
fclose($fp);
Jest to fragment funkcji która podmieniała by zmienne w pliku tpl na ich wartość zdefiniowaną w pliku index.php
Kod
$tpl -> varible(array("lol" => 'Jesteś noobem',
"noob" => 'Jesteś lolem'));
"noob" => 'Jesteś lolem'));
w pliku index.tpl mam wpisane
Kod
{$lol}
{$noob]
{$noob]
problem w tym że nie wyświetla się nic. :/
Pomóżcie