Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Rotator - jak dopiąć kod z pliku txt ?
Xe41
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 10.01.2007

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


Mam taki skrypt:
  1. <?php
  2.  
  3. $maxLinks = 5;
  4.  
  5. // Lista linkow
  6. $links = array(
  7. array( 'http://www.costam.pll/', 'anchor' ),
  8. array( 'http://www.costam2.pl/', 'anchor2' )
  9. );
  10.  
  11. srand ( ( float ) microtime() * 10000000 );
  12. $random = array_rand( $links, $maxLinks );
  13. if ( is_array( $random ) )
  14. {
  15. foreach ( $random AS $value )
  16. {
  17. print '<a href="' . $links[ $value ][0] . '" target="_blank">' . $links[ $value ][1] . '</a><br />';
  18. }
  19. }
  20. else
  21. {
  22. print '<a href="' . $links[ $random ][0] . '" target="_blank">' . $links[ $random ][1] . '</a>';
  23. }
  24.  
  25. ?>

Chciałbym zrobić tak, by zamiast linków w kodzie móc dodawać linki w pliku txt.
Help :')


Albo jak przerobić w ten sam sposób by móc w txt dodawać owy skrypt:
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. Array.prototype.random = function(limit)
  4. {
  5. if (typeof limit == 'undefined' || limit < 0) limit = 1;
  6. else if (!limit) limit = this.length;
  7. for (var i = 0, source = this, target = new Array(), n = source.length; i < limit && n > 0; i++)
  8. {
  9. do { var index = Math.random(); } while (index == 1);
  10. index = Math.floor(index * n);
  11. target.push(source[index]);
  12. source[index] = source[--n];
  13. }
  14. return target;
  15. }
  16.  
  17. document.write(new Array(
  18. // Tu wpisz kolejne elementy:
  19.  
  20. 'Tekst 1',
  21. 'Tekst 2',
  22. 'Tekst 3'
  23.  
  24. ).random().join(''));
  25. // ]]>
  26. </script>


Ten post edytował Xe41 1.02.2010, 14:46:25
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: 23.08.2025 - 01:21