【发布时间】:2018-11-19 10:10:36
【问题描述】:
有人可以帮助我使用随机或顺序 api 列表编写执行数据的代码
我有 10 个数据和 3 个 api 列表,我希望代码这样做:
data 1 executed by api 1
data 2 executed by api 2
data 3 executed by api 3
data 4 executed by api 1
data 5 executed by api 2
data 6 executed by api 3
data 7 executed by api 1
data 8 executed by api 2
data 9 executed by api 3
data 10 executed by api 1
我尝试像这样编写代码,结果与我预期的不一样:
if(isset($argv[1])){
$no = 1;
$api = 0;
$total = count(explode("\n",file_get_contents($argv[1])));
$listapi = file_get_contents($argv[2]);
$listml = file_get_contents($argv[1]);
$ex = explode("\n",$listapi);
$exx = explode("\n",$listml);
for ($ee = 0; $ee < count($exx); $ee++) {
for ($api = -1; $api < count($listapi); $api++) {
$send = json_decode($curl->get($ex[$api]."?ee=".$exx[$ee]));
$no++;
echo "OK\n";
if ($api % count($ex) == 3) {
$api = -1;
echo "Rolling\n";
}
}
}
【问题讨论】: