napisałem sobie taką klasę do obsługi szablonów
<?php class Themes { private $data; private $file; private $key; private $value; public function add($pattern, $command) { /* $tablica[$pattern] = $command; $this->data[$pattern] .= $tablica[$pattern]; */ $key[] = '%{'.$pattern.'}%'; $value[] = $command; $this->key = $key; $this->value=$value; } public function load($file) { $this->file = $op; return true; } public function debug() { } public function show() { //echo 'Klucz: '.$key.', Wartosc: '.$value.'<br />'; // //$content = preg_replace('%{'.$key.'}%', $value, $this->file); //$content .= str_replace('{'.$key.'}', ''.$value.'', $this->file); return true; } } $szablon = new Themes(); $szablon->add('imie', 'Piotr'); $szablon->add('kupa', 'z dupy wychodzi'); $szablon->add('d', 'asdasdasd'); $szablon->load('pomoce/123.php'); $szablon->show(); $szablon->debug(); ?>
no i teraz jak wstawie w pliku pomoce.123.php
Kod
Moje imie to {imie}
Kupsko: {kupa}
Reszta: {d}
to zamienia tylko jeden element.
jak zrobic zeby zamieniało wszystko?