Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [smarty] funkcje w smarty
pawel.b
post
Post #1





Grupa: Zarejestrowani
Postów: 25
Pomógł: 2
Dołączył: 5.02.2009
Skąd: Kraków

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


witam

mam w php funkcje którą rejestruje w smarty funkcja przyjmuje 3 parametry i zwraca tablice
Kod
function make_seed()
{
     list($usec,$sec) = explode(" ", microtime());
     return ((float)$sec+(float)$usec) * 100000;
}
mt_srand(make_seed());

function randomArray($params, &$smarty)
{
     $tmp = array();
     while(count($tmp) < $params['counter'])
     {
         $rand = mt_rand($params['from'],$params['to']);
         if(! in_array($rand,$tmp))
             $tmp[] = $rand;
     }
     return $tmp;
}

$smarty->register_function('randomArray','randomArray');

w szablonie mam tak
Kod
{capture name=returned_array}
    {randomArray counter=5 from=0 to=30}
{/capture}
{assign var=randArr value=$smarty.capture.returned_arry}
{$randArr[0]}

i oczywiście nie działa
pomożecie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

dzięki za pomoc

Ten post edytował pawel.b 27.03.2009, 11:03:31
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




to nie mogles od razu napisac w czym problem?

widze pewną niescisclosc miedzy slowem:
returned_array
a:
returned_arry

bbcode dla php to [php] a nie [code]
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 3.10.2025 - 10:15