Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Tablice a szablony
samouk
post
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 15.07.2013

Ostrzeżenie: (0%)
-----


Witam

Może na początku kod:

  1. $kraje = Array(
  2. 'Europa' => array('Polska', 'Anglia', 'Litwa', 'Francja'),
  3. 'Afryka' => array('Tunezja', 'Egipt', 'RPA', 'Etiopia'),
  4. 'Azja' => array('Chiny', 'Mongolia', 'Japonia', 'Kazachstan')
  5. );
  6.  
  7. $szablon->assign('kraj', $kraje);


  1. public function assign($tpl_var, $value = null)
  2. {
  3. if (is_array($tpl_var)){
  4. foreach ($tpl_var as $key => $val){
  5. if ($key != ''){
  6. $this -> vars[$key] = $val;
  7. }
  8. }
  9. }else{
  10. if ($tpl_var != '')
  11. $this -> vars[$tpl_var] = $value;
  12. }
  13. }


  1. foreach ($this->vars as $regexp => $replace) {
  2. $source = preg_replace("#".$this -> lt."!". $regexp .$this -> rt."#si",$replace,$source);
  3. }


I teraz otrzymuję błąd na stronie:

Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in
Jak wstawić tak bym mógł optymalnie wyświetlać tablice?
Go to the top of the page
+Quote Post

Posty w temacie
- samouk   [PHP]Tablice a szablony   4.08.2013, 11:49:19


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 03:14