- substr: documentation ( source)
- chr: documentation ( source)
- microtime: documentation ( source)
- str_shuffle: documentation ( source)
- rand: documentation ( source)
<?php
$timeStart = microtime(true);
$rand = substr(str_shuffle('a-Z strings'), 5, 5);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
echo "Code 1: $time seconds\n";
$timeStart = microtime(true);
for ($i = 0; $i <= 5; ++$i) {
$rand .= chr(rand(99, 155));
}
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
echo "Code 2: $time seconds\n";