Skip to content

Instantly share code, notes, and snippets.

@atakde
Last active November 8, 2022 20:32
Show Gist options
  • Save atakde/318d09c94eb780bf67fa08790c0cbf7a to your computer and use it in GitHub Desktop.
Save atakde/318d09c94eb780bf67fa08790c0cbf7a 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) {
$array[$k] = $v + 1;
}
echo "Completed in ", microtime(true) - $start, " Seconds\n";
$start = microtime(true);
foreach ($array as $k => &$v) {
$v = $v + 1;
}
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