Skip to content

Instantly share code, notes, and snippets.

@atakde
Created November 8, 2022 20:37
Show Gist options
  • Save atakde/89e7aa7740b220eb61d1e18a7842c015 to your computer and use it in GitHub Desktop.
Save atakde/89e7aa7740b220eb61d1e18a7842c015 to your computer and use it in GitHub Desktop.
<?php
$array = [];
for ($i = 0; $i < 10000; $i++) {
$array[] = $i;
}
$start = microtime(true);
foreach ($array as $k => $v) {
// empty code.
}
echo "Completed in ", microtime(true) - $start, " Seconds\n";
$start = microtime(true);
foreach ($array as $k => &$v) {
// empty code.
}
echo "Completed in ", microtime(true) - $start, " Seconds\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment