curl_multi_init question

Discussion in 'PHP' started by redhits, Nov 12, 2009.

  1. #1
    I have a question ... about curl_multi_ini i could not find on php.net

    how i can print out the websites? like website[0] website[1] website[2]

    ?
    <CODE>
    <?php
    set_time_limit(300);
    echo "<br>Start time: ".date("H:i:s").'<br>'; flush();

    $url[1]='http://www.geoseo.com/30sec.php';
    $url[2]='http://www.geoseo.com/30sec.php';
    $url[3]='http://www.geoseo.com/30sec.php';



    $ch1 = curl_init();
    $ch2 = curl_init();
    $ch3 = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch1, CURLOPT_URL, $url[1]);
    curl_setopt($ch1, CURLOPT_HEADER, 0);
    curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch2, CURLOPT_URL, $url[2]);
    curl_setopt($ch2, CURLOPT_HEADER, 0);
    curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch3, CURLOPT_URL, $url[3]);
    curl_setopt($ch3, CURLOPT_HEADER, 0);
    curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1);


    $mh = curl_multi_init();

    //add the two handles
    curl_multi_add_handle($mh,$ch1);
    curl_multi_add_handle($mh,$ch2);
    curl_multi_add_handle($mh,$ch3);


    $running=null;
    //execute the handles
    do {
    curl_multi_exec($mh,$running);
    } while ($running > 0);


    echo "<br>$mh[0]";
    echo "<br>$mh[1]";
    echo "<br>$mh[2]";


    //close the handles
    curl_multi_remove_handle($mh, $ch1);
    curl_multi_remove_handle($mh, $ch2);
    curl_multi_remove_handle($mh, $ch3);
    curl_multi_close($mh);

    echo "<br>Stop time: ".date("H:i:s").'<br>';

    ?>
    </CODE>
     
    redhits, Nov 12, 2009 IP