I am pretty sure that this function should do the trick for you, you can adjust it for points after the decimal if needed:
Edit: Did a touch of actual testing and modified the code ever so slightly (as well as adding loads of output for you to see what is happening:
<?php
function chance($input=array())
{
echo 'The Max Value can be: '.(array_sum($input)*10).'<br>';
$number=rand(0,array_sum($input)*10);
echo 'Checking for: '.$number.'<br>';
$starter=0;
foreach($input as $key => $val)
{
$starter+=$val*10;
echo 'Current value being tested against is: '.$starter.' which is '.$key.'<br>';
if($number<=$starter)
{
$ret=$key;
break;
}
}
return $ret;
}
$array=array('Blue' => 15.3, 'Red' => 64.7, 'Green' => 20.0);
for($i=0;$i<10;$i++)
{
echo chance($array).'<br><br>';
}
?>
Example Output:
The Max Value can be: 1000
Checking for: 355
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red
The Max Value can be: 1000
Checking for: 63
Current value being tested against is: 153 which is Blue
Blue
The Max Value can be: 1000
Checking for: 692
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red
The Max Value can be: 1000
Checking for: 803
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Current value being tested against is: 1000 which is Green
Green
The Max Value can be: 1000
Checking for: 360
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red
The Max Value can be: 1000
Checking for: 174
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red
The Max Value can be: 1000
Checking for: 117
Current value being tested against is: 153 which is Blue
Blue
The Max Value can be: 1000
Checking for: 769
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red
The Max Value can be: 1000
Checking for: 462
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red
The Max Value can be: 1000
Checking for: 418
Current value being tested against is: 153 which is Blue
Current value being tested against is: 800 which is Red
Red