Jump to content

About percentage


hackerkts

Recommended Posts

Let's say I have this,
[code]$type1 = '5'; // all the values are in %
$type2 = 15'';
$type3 = 20'';
$type4 = 50'';
$type5 = 10'';[/code]

Is it possible to assign them to
$type1_result = '11111';
$type2_result = '222222222222222';
$type3_result = '33333333333333333333';
$type4_result = '44444444444444444444444444444444444444444444444444';
$type5_resul = '5555555555';

Hope you understand what I'm trying to say..
Link to comment
Share on other sites

Hmm ok, I will explain again..
If I put $A = 10;
Then I had another var, which is what I couldn't figure out myself.
Let's say that var is $A_Result, then I want the vaule of $A_Result to be AAAAAAAAAA. (There are 10's A)

So the value of $A_Result is depended on the value of $A.
Hmm.. Is this clear ?

To make it more clearer, this is the code I'm using now.
[code]    function rtd($length)
{
$dice1 = '5'; // Dice 1
$dice2 = '15'; // Dice 2
$dice3 = '20'; // Dice 3
$dice4 = '50'; // Dice 4
$dice5 = '10'; // Dice 5
$dice6 = '0'; // Dice 6

$chars = $dice1 . $dice2 . $dice3 . $dice4 . $dice5 . $dice6;
for ($x = 1; $x <= $length; $x++)
{
$number = rand(1, strlen($chars));
$dice .= substr($chars, $number - 1, 1);
}

return $dice;
}[/code]

Then when I echo out $dice, there's 5% will be Dice 1, 15% to be Dice 2, 20% to be Dice 3, 50% to be Dice 4, 10% to be Dice 5 and 0% to be Dice 6
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.