【发布时间】:2020-03-31 01:40:23
【问题描述】:
我的代码有问题。我想做的是在数组被调用时从数组中删除一个项目,这意味着我希望每个输出都不同。我想用它来旋转代理,阵列中有超过 150 个代理。这是我的代码示例。
for ( $i = 1; $i < 2; $i++ )
{
// If the array_history is empty, re-populate it.
if (empty($array_history))
$array_history = $array;
// Select a random key.
$key = array_rand($array_history, 1);
// Save the record in $selected.
$selected = $array_history[$key];
// Remove the key/pair from the array.
unset($array_history[$key]);
// Echo the selected value.
echo $selected;
}
我该怎么做,或者 for 循环不适合这个?提前致谢。
【问题讨论】:
-
不清楚您要达到的目标。请提供一些示例数据以及您想要的输出。看看How to Ask 和edit 你的问题。
-
我已经编辑了我的问题并解释了更多,你能帮忙
标签: php arrays for-loop variables arraylist