echo "欢迎您和我们一起学习PHP!";
echo "
";
//第一种方法
$numbers = range (0,100);
shuffle ($numbers);
//array_slice 取该数组中的某一段
echo "排序前:";
$no=20;
$result = array_slice($numbers,0,$no);
for ($i=0;$i
echo "".$result[$i].""."\n";
}
echo "
";
echo "排序后:";
sort ($result);
//echo "".join (' ',$result)."";
for ($w=0;$w
echo "".$result[$w].""."\n";
}
echo"
";
//第二种方法
$tmp=array();
while(count($tmp)<20){
$tmp[]=mt_rand(0,100);
$tmp=array_unique($tmp);
}
echo "排序前:";
echo join(',',$tmp);
echo "
";
echo "排序后:" ;
sort($tmp);
echo implode(',',$tmp);
?>