- microtime: documentation ( source)
<?php
$a = 1;
$b = 2;
$time = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
list($a, $b) = [$b, $a];
}
echo microtime(true) - $time . PHP_EOL;
$time = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$t = $a; $a = $b; $b = $t;
}
echo microtime(true) - $time . PHP_EOL;