- array_push: documentation ( source)
- microtime: documentation ( source)
- number_format: documentation ( source)
<?php
$start = microtime(true);
$arr = [];
for ($i = 0; $i < 1000; $i++) {
array_push($arr, $i);
}
$end = microtime(true);
echo number_format($end - $start, 8, '.', '') . "\n";
unset($arr);
$start = microtime(true);
$arr = [];
for ($i = 0; $i < 1000; $i++) {
$arr[] = $i;
}
$end = microtime(true);
echo number_format($end - $start, 8, '.', '') . "\n";