- microtime: documentation ( source)
- round: documentation ( source)
- array_fill: documentation ( source)
<?php
$arr = array_fill(0, 500000, ['test' => 'hello']);
$start = microtime(true);
foreach ($arr as $ar) {}
echo 'Array Iteration :' . round(microtime(true) - $start, 4) . "\n";
$arr = SplFixedArray::fromArray($arr);
$start = microtime(true);
foreach ($arr as $ar) {}
echo 'SPL Iteration :' . round(microtime(true) - $start, 4) . "\n";