So, we have 6 numbers (123456). It is necessary that the numbers 1 and 2 have a 70% chance of falling out, and 3456 have a chance of 30%.

Tell me, please, how to implement php?

    2 answers 2

    $n = rand(1,1000); if ($n <= 350) { echo 1; } elseif ($n <= 700) { echo 2; } elseif ($n <= 775) { echo 3; } elseif ($n <= 850) { echo 4; } elseif ($n <= 925) { echo 5; } else { echo 6; } 
    • I have already planned this option, but thanks anyway. - wiggy
    • one
      @wiggy - I really apologize, what is this boorish comment? - Igor

    Here it is possible

     $v = rand(1,100) <= 70 ? rand (1, 2) : rand(3, 6);