- microtime: documentation ( source)
<?php
$a = array();
for ($i = 0; $i < 10000; $i++) {
$a[$i] = 1;
}
$start = microtime(true);
$count = count($a);
for ($i = 0; $i < $count; $i++) {}
echo "Completed in ", microtime(true) - $start, " Seconds\n";
$start = microtime(true);
foreach ($a as $k => $v) {}
echo "Completed in ", microtime(true) - $start, " Seconds\n";
$start = microtime(true);
foreach ($a as $k => &$v) {}
echo "Completed in ", microtime(true) - $start, " Seconds\n";