经过一番搜索,我发现这个带加密的youtube样式url生成器隐藏了原始id ...但是我希望提高效率,因为它会被大量使用.到目前为止,我已经将它提高了20%......任何人都可以帮我改进它.
这是原作:
function alphaID($in, $to_num = false, $pad_up = false, $passKey = null)
{
$index = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if ($passKey !== null) {
// Although this function's purpose is to just make the
// ID short - and not so much secure,
// with this patch by Simon Franz (http://blog.snaky.org/)
// you can optionally supply a password to make it harder
// to calculate the corresponding numeric ID
for ($n = 0; $n<strlen($index); $n++) {
$i[] = substr( $index,$n ,1); …
Run Code Online (Sandbox Code Playgroud) 我很困惑为什么:
echo log10(238328) / log10(62);
Run Code Online (Sandbox Code Playgroud)
结果3
但
echo floor(log10(238328) / log10(62));
Run Code Online (Sandbox Code Playgroud)
结果2
我知道地板向下,但我认为它只适用于十进制数字.
如何在通常四舍五入的同时得到后一种判断中的3种答案?