This is very easy to do.
Watch for the comments in the code below.
$priorities = array(
6=> 10,
5=> 40,
4=> 35,
3=> 5,
2=> 5
);
# you put each of the values N times, based on N being the probability
# each occurrence of the number in the array is a chance it will get picked up
# same is with lotteries
$numbers = array();
foreach($priorities as $k=>$v){
for($i=0; $i<$v; $i++)
$numbers[] = $k;
}
# then you just pick a random value from the array
# the more occurrences, the more chances, and the occurrences are based on "priority"
$entry = $numbers[array_rand($numbers)];
echo "x: ".$entry;