Jump to content

Recommended Posts

I'll try as best as I can.

 

I have an array but I don't know how big it'll be.

I count the number of columns in the database and then select a random number. rand(1, $row['COUNT(id)']);

Then from that, it selects the column of the random number.

 

There is a column called probability. It calculates the chances of the thing being true out of 100. Then, whatever the probability number is, that is the size the array is going to be and another variable adds a random number to each array.

 

Then, there is some other stuff but it isn't relevant.

if your probability number is... lets say 17, then

 

howabout:

 

for ( $min= 1; $max<= 17; $counter ++) {

 

$myarray[] = $counter;

 

}

 

for output:

 

print_r($myarray);

 

Well ... that helps out a little but I got that far. I guess I'm just looking for some kind of function to set the dimension of an array. Well hang on, this is how it works:

 

Say 5 was the prob number:

within your for loop

 

$numbers[$counter]; // Same as: $numbers['1'];

$numbers[$counter]; // Same as: $numbers['2'];

 

and so on ...

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.