Jump to content

Recommended Posts

            RAIN    SNOW  FOG  WIND

SPRING    30%    0%      30%  30%

SUMMER  15%    0%      30%  30%

FALL      10%    0%      30%  30%

WINTER  10%    30%    40% 30%

 

how can i base in the percentage of all the given data for example:

 

spring  has to be 30%(rain,snow,fog,wind) probability

and make a random function with exact probobility?

thnx guys

 

Link to comment
https://forums.phpfreaks.com/topic/168299-random-base-on-a-percentage/
Share on other sites

<?php

$a = rand(1,100);

?>

 

This will get a random number between 1 and 100 (to check the first condition)

if the number is between 1 and 30, it will rain. 31-60 it will be foggy. 61-90 it will be windy.  I guess 91-100 would be a clear sunny day ?  that isn't really stipulated in your condition

 

you can use the same basic calculation for the others

<?php

$a = rand(1,100);

?>

 

This will get a random number between 1 and 100 (to check the first condition)

if the number is between 1 and 30, it will rain. 31-60 it will be foggy. 61-90 it will be windy.  I guess 91-100 would be a clear sunny day ?  that isn't really stipulated in your condition

 

you can use the same basic calculation for the others

i think this is it man thanks ill try this..thnx to all
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.