- var_dump: documentation ( source)
- microtime: documentation ( source)
- range: documentation ( source)
<?php
$array = range(0, 50000);
$n = 300;
$t = microtime(true);
for ($i = 0; $i < $n; $i++) {
foreach ($array as $v) { }
}
var_dump(microtime(true) - $t);
$t = microtime(true);
for ($i = 0; $i < $n; $i++) {
for ($j = 0, $c = count($array); $j < $c; $j++) {
$v = $array[$j];
}
}
var_dump(microtime(true) - $t);