Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z zamiana
Forum PHP.pl > Forum > PHP
jarek
Witam,

Mam taki problem pisze obecnie projekt w którym chce wykorzystać templaty cos takiego jak w phpBB2. Tylko nie wiem jak sie zabrac do tego aby skrypt po przeanalizowaniu zawartosci pliku template znalazl wszystkie wyrazenia bedace w formie np. {TYTUL} i zamienil je na odpowiednie elementy tablicy w tym wypadku chcialbym aby zamienialo to na $element['TYTUL'].

Bardzo prosze o pomoc i z góry dziękuje.


pozdrawiam
jarek
Officerrr
z manuala php
[ciach]

str_replace (mixed search, mixed replace, mixed subject)
This function returns a string or an array with all occurences of search in subject replaced with the given replace value. If you don't need fancy replacing rules, you should always use this function instead of ereg_replace() or preg_replace().

In php 4.0.5 and later, every parameter to str_replace() can be an array.

If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.

If search and replace are arrays, then str_replace() takes a value from each array and uses them to do search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values. If search is an array and replace is a string; then this replacement string is used for every value of search. The converse would not make sense, though.

Przykład 1. str_replace() example
$bodytag = str_replace("%body%", "black", "<body text=%body%>");

[/ciach]
hyper
Zamiast sikać pod wiatr proponowałbym zainteresowanie się:

Smarty - http://smarty.php.net/
FastTemplates - idunno
haiaw
Cytat
Zamiast sikać pod wiatr proponowałbym zainteresowanie się:

Smarty - http://smarty.php.net/
FastTemplates - idunno


Smarty to jeden z najbardziej rozbudowanych systemow templeatowych.
W dodatku na standardowej instalacji php ( bez akceleratorow) jest bardzo wolny.
Dlatego tez na prywatny uzytek polecam jednak Fast Templates
jarek
a gdzie moge zdobyc fast template?
jarek
ok mam juz dzieki http://phpclasses.mysiar.net/browse.html/p...package/23.html
hyper
Cytat
Smarty to jeden z najbardziej rozbudowanych systemow templeatowych.
W dodatku na standardowej instalacji php ( bez akceleratorow) jest bardzo wolny.  
Dlatego tez na prywatny uzytek polecam jednak Fast Templates


Jesli zastosowac cachowanie strony to wcale nie wychodzi tak zle.
haiaw
Cytat
Cytat
Smarty to jeden z najbardziej rozbudowanych systemow templeatowych.
W dodatku na standardowej instalacji php ( bez akceleratorow) jest bardzo wolny.  
Dlatego tez na prywatny uzytek polecam jednak Fast Templates


Jesli zastosowac cachowanie strony to wcale nie wychodzi tak zle.



Ale cachowanie to nie zawsze dobry pomysl. 8)

http://www.phpinsider.com/php/code/Smarty/benchmarks/
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.