Copy code The code is as follows:
echo 'begin time:'.$begin=microtime(false) .'
';//begin to count time
$array=array();
for ($i=1;$i<=10000;$i++) {//Generate a Very large array
$array[$i]=$i;
}
/*
$arr=$array;//Total copy and print time 0.02
foreach ($ arr as $ar) {
echo $ar.'
';
}
*/
/*
$newarr=&$array;//Address reference The advantage of address reference that time is always controlled within 0.01 is reflected in
foreach ($newarr as $r) {
echo $r.'
';
}
*/
foreach ($array as $a) {//Basically 0.02, rarely 0.01 Why is it not as fast as address reference? Wondering
echo $a.'
';
}
echo 'end time:'.$end=microtime(false).'
';// end to count time
echo 'total time:'.($end-$begin);
?>
http://www.bkjia.com/PHPjc/325221.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325221.htmlTechArticleCopy the code as follows: ?php echo 'begin time:'.$begin=microtime(false).'br /';//begin to count time $array=array(); for ($i=1;$i=10000;$i++) {//Generate a large array $arra...