I have an array of elements:
$arr = array(
'0' => 265000, // Area
'1' => 190000,
'2' => 30000,
'3' => 1300
);
I want to get random index based on the area (Array value). I need the area with big value be selected more frequently. How can I do this?
What I have now:
$random_idx = mt_rand(0, count($arr)-1);
$selected_area = (object)$arr[$random_idx];
Thanks!
Aucun commentaire:
Enregistrer un commentaire