- chr: documentation ( source)
- microtime: documentation ( source)
- str_rot13: documentation ( source)
- ord: documentation ( source)
<?php
function rot13($str) {
for ($i = 0,$l = strlen($str);$i<$l;$i++) {
$str[$i] = chr(((ord($str[$i])-84)%26)+97);
}
return $str;
}
$d = '';$i=$e=0;
$start = microtime(1);
while($i++ < 500000) $d = str_rot13('rotate 13');
echo microtime(1) - $start;
echo "\n";
$d = '';
$start = microtime(1);
while($e++ < 500000) $d = rot13('rotate 13');
echo microtime(1) - $start;