- var_dump: documentation ( source)
- uniqid: documentation ( source)
- microtime: documentation ( source)
- array_fill: documentation ( source)
- printf: documentation ( source)
<?php
$array = array_fill(0, 100, uniqid('', false));
$array2 = $array;
$timer = microtime(true);
for ($i = 0; $i < 10; $i++) {
while (list($key, $value) = each($array)) {
$array[$key] = 'value';
}
}
printf("While list each %.3f sec\n", microtime(true) - $timer);
$timer = microtime(true);
for ($i = 0; $i < 10; $i++) {
foreach ($array2 as $key => &$value) {
$value = 'value';
}
}
printf("Foreach %.3f sec\n", microtime(true) - $timer);
var_dump(count($array), count($array2));
var_dump($array === $array2);