Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][HTML] Funkcja zwracająca wartości naprzemian
Efan
post
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 25.01.2007

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


Potrzebuję funkcji która zwraca naprzemian wartości

Generalnie chodzi o:
  1. <table background="Wartosc1"><tr><td></td></tr></table>
  2. <table background="Wartosc2"><tr><td></td></tr></table>
  3. <table background="Wartosc1"><tr><td></td></tr></table>
  4. <table background="Wartosc2"><tr><td></td></tr></table>
  5. ...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
phpion
post
Post #2





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




W Kohana jest fajny helper text::alternate. Jego kod sprowadza się do:
  1. class text {
  2. /**
  3. * Alternates between two or more strings.
  4. *
  5. * @param string strings to alternate between
  6. * @return string
  7. */
  8. public static function alternate()
  9. {
  10. static $i;
  11.  
  12. if (func_num_args() === 0)
  13. {
  14. $i = 0;
  15. return '';
  16. }
  17.  
  18. $args = func_get_args();
  19. return $args[($i++ % count($args))];
  20. }
  21. }
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: 16.10.2025 - 15:31