AKoyun arkadaşımızın verdiği örneği deneyebilirisiniz.

bu da aleternatif

<?php
    function host( $url )
    {
        $parsed = parse_url($url);

        return  isset($parsed['host']) ? $parsed['host'] :  '';
    }


    function is_online( $host )
    {
        return @fsockopen($host,80,$errno,$errstr,1);
    }

    $text = array();
    $text[1] = "http://zzzzz";
    $text[2] = "http://www.google.com";
    $text[3] = "http://127.0.0.1";


    while (!($url_online = is_online(host($rastgele_url = $text[$index = array_rand($text)]))) && $url_var = count($text))
        unset($text[$index]);



    if ($url_online)
    {
        echo $rastgele_url.' rasgtgele seçildi ve şuan online.';
    }
    else
    {
        echo 'tüm adresler denendi ama online bulunamadı.';
    }

?>