The answer to your question, as others have pointed out, is that your code fails without returning. If it 2returns by calling rand () both on the first attempt and on the second attempt (there is a 1/16 probability of this case), you will get 2the result.
But your approach to solving the problem could be better.
, . , . ( , , .)
, . (1, 3 4.) , , . if. . , - PHPfu .
function pickServer() {
$remap = array(1, 3, 4);
return $remap[rand(1,3)];
}
function pickServer() {
$server = rand(1,3);
if ($server==2) {
$server=4;
}
return $server;
}
, . if . , 2-4, 1, .