Hola,
Código PHP:
Ver original 2 => 10,
4 => 10,
12 => 10,
24 => 30,
);
function normalize($n) {
global $weights;
$s = 0;
foreach ($weights as $key => $value) {
$s += $value;
if ($s >= $n) return $key;
}
return false;
}
function randomizer() {
global $totalWeight;
return normalize($i);
}
echo "select * from objects where id = " . randomizer();
En $weights tienes un array asociativo con el peso de cada id.
Saludos,
ps:
http://www.forosdelweb.com/f13/bajar...ricion-750353/