PHP代码执行权重优先级
生成所有数组再根据随机数根据key定位到id
$arr = [
1=>12,
2=>123,
3=>12,
4=>111,
];
$supplier = [];
foreach ($arr as $key=>$item) {
$supplier = array_merge($supplier,array_fill(0,$item,$key));
}
echo $supplier[rand(0,count($supplier)-1)];exit;