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?

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.
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.