复制代码 代码如下:
$arrF = array();
$arrS = array();
$intTotal = 100;
$intRand = 10;
for($i=0; $i {
$arrF[] = rand(1, $intRand);
$arrS[] = rand(1, $intRand);
}
$arrT = array_merge($arrF, $arrS);
$arrRF = array();
$intStart = time();
foreach($arrT as $v)
{
if(in_array($v, $arrRF))
{
continue;
}
else
{
$arrRF[] = $v;
}
}
$intEnd = time();
$intTime = $intEnd-$intStart;
echo "With Continue,Spend time:$intTime
";
$intStart1 = time();
$arrRS = array_unique($arrT);
$intEnd2 = time();
$intTime2 = $intEnd2-$intStart1;
echo "With array_unique function,Spend time:($intTime2)";
echo "
"; <br>print_r($arrT); <br>print_r($arrRF); <br>print_r($arrRS); <br>echo "