$a = [
'a' => 1,
'b' => 0.11,
'c' => 0.5,
'd' => 1,
'e' => 0.02,
'f' => 0.0000005,
// ...
];
$sum = array_sum($a);
$rnd = rand() / getrandmax(); // от 0 до 1
$runningSum = 0;
foreach($a as $k => $v) {
$runningSum += $v / $sum;
if ($runningSum >= $rnd) {
$key = $k;
break;
}
}
if (!$key) $key = $k;
echo "Выпало: " . $key . PHP_EOL;