Running multiple PHP script at once with register_shutdown_function


I am using the following code capture different URLs:

        $array_URLs = array();        
            $array_URLs[] = $_POST['URL'.$x];

After that I run the following code so I can execute a function before the script ends:

register_shutdown_function(array('Export', 'myExportFuncion'));

Now I need to run each URL given in the $array_URLs as it was called from the web browser. However I need to execute myExportFuncion only when all URLs are executed. I am trying to use the following code to achieve this:

    foreach($array_URLs as $URL){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $URL);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $output = curl_exec($ch);


The above code does not generate the expected result. What would be the best approach to this problem?

Show source
| url   | php   2017-01-06 16:01 0 Answers

Answers ( 0 )

◀ Go back