Jump to content

[SOLVED] 'Random' result, but giving possiblity?


Michdd

Recommended Posts

You could maybe use shuffle with an array if that's what you mean?

Edit:

To be annoying:

 

Anything is possible, so yes it is possible, but what you are most likely asking is can we show you how?

Yea sorry, I know most things are possible, but I wasn't sure if this was possible, with shuffle you can set 1 thing to be output more commonly than another thing? If so, how?

Link to comment
Share on other sites

I think you are stuck on the logic?

 

Example

 

<?php
$arr = array(
'1',
'1',
'2'
);
echo shuffle($arr[0]);// it has a 2 in 3 chance of printing the number 1
?>

or

<?php
$num = rand(0,3);//make a random number between 1 & 100
$arr = array(
'1',
'2',
'3'
);
echo $arr[$num];// this will show each one with the same chance.
?>

Link to comment
Share on other sites

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.