dongmo9996 2019-04-12 07:56
浏览 109

在foreach循环中多次运行PHP文件

I have an array with 12500 elements (company IDs). I need run 1 PHP file for all the elements in the array.

Please let me know what is the best way to do that.

I want to use Curl inside the for each loop to execute the file:

<?php

$array = ['123','124','125','126','127',......,'12503'];
    foreach ($array as &$value) {
        $url = 'https://*****/*****/List_daily.php?accountid='.$value.'';
        $resp = call_curl($url);
        echo $resp."<br>"

        /**
            Here is where I want to execute the file
        **/
    }

    function call_curl($url){
        $curl = curl_init();
        curl_setopt_array($curl, array(
                CURLOPT_URL => $url,
                CURLOPT_TIMEOUT => '5'
            ));
        $resp = curl_exec($curl);
        curl_close($curl);
        return $resp;
    }
?>
  • 写回答

2条回答 默认 最新

  • douyan8772 2019-04-12 08:12
    关注

    You can try parallel curl requests for the array you have to have better performance, you can use this as an example PHP Parallel curl requests

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入