From 0f855daa71e745d8ab0df8c5bae0295c8ac68b5c Mon Sep 17 00:00:00 2001 From: Juribiyan Date: Wed, 11 Jul 2018 22:03:18 +0500 Subject: [PATCH] Fix captcha bug caused by different decimal point in some environments --- nrand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nrand.php b/nrand.php index dd1d748..a22232e 100644 --- a/nrand.php +++ b/nrand.php @@ -158,10 +158,10 @@ function generate_code($length = 7) { foreach($charset as $char) { $balanced = $freqs[$char] / $sum; $bsum += $balanced; - $xfq[(string)$bsum] = $char; + $xfq[$char] = $bsum; } $roll = frand(); - foreach($xfq as $freq => $letter) { + foreach($xfq as $letter => $freq) { if($roll < $freq) { $result[$i] = $letter; $roll = 2;