array('method'=>"GET",'timeout'=>3,)); $context = stream_context_create($opts); try { $homepage = file_get_contents($hosts[$i], false, $context); } catch (Exception $e) { echo($e); } $ends = array_sum(explode(" ",microtime())); if ($homepage==NULL ||$homepage="") { $diff=60.0; } else { $diff=$ends-$start; } if ($mint > $diff) { $mint=$diff; $s_url=$hosts[$i]; } } return $s_url; } }