Facebook
From Sexy Finch, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 60
  1. <?php
  2.  
  3. $serwery = array("www.gdansk.pl", "www.trojmiasto.pl", "www.dziennikbaltycki.pl");
  4. $serwer_time = array();
  5. foreach($serwery as $link)
  6. {
  7.     $serwer_time[] = http_ping($link);
  8. }
  9. print(var_dump($serwery));
  10. print("<br/>");
  11. print(var_dump($serwer_time));
  12. print("<br/>");
  13. $key = array_search(min($serwer_time),$serwer_time);
  14. echo 'key '.$key;
  15. print("<br/>");
  16. echo ' czas='.min($serwer_time);
  17. print("<br/>");
  18. $url = 'Location: '.$serwery[$key];
  19. echo ' url='.$url;
  20. header('Location: http://'.$serwery[$key]);
  21.  
  22. function http_ping($serwer)
  23. {
  24.     $czas = microtime(true);
  25.     $str = file('http://'.$serwer);
  26.     return microtime(true) - $czas;
  27. }
  28.  
  29. ?>