Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 PHP 中绘制 1 到 100 之间的随机数。我希望以 20% 的概率抽取偶数,以 80% 的概率抽取奇数。
我该如何实施?
function wtf_random() { $ret = 2 * rand(1, 50); if (rand(1, 5) !== 1) { --$ret; } return $ret; }