1. random array

How do I output the numbers, 1-11 in a random order like 5, 7, 4, 11, 2, 3, 1, 9, 6, 8, 10

2. populate an array, call shuffle on it, loop over it and output each item

3. No offense intended Luke, but IMHO PHP has a fairly well documented manual http://www.php.net/manual/en/function.rand.php
Is there something that fails to do for your needs?

4. ok, thx

5. I'm trying to figure out the answer to this sample question...

1. In PHP, create a randomized array with values 1-11, where the first three elements are grouped together.
Example Output: 5, 7, 4, 11, 2, 3, 1, 9, 6, 8, 10

I know how to generate a random number from 1 to 11 (rand(1,11)) and dont even know where to start (the question doesnt even seem like something like that is doable) Can you give me a point in the right direction?

6. What do you mean by "grouped together", an array or cocatenated?

7. PHP Code:
``` \$startArray = range(1, 11); // create an array containing the values 1 through 11shuffle(\$startArray); // shuffle them so they are in a random orderecho join(', ', \$startArray); // output them to the screen  ```

8. I lloks like after the array is shuffled, the first three elements (1, 2, 3) are grouped together in the array?
Is this ok?
PHP Code:
``` \$startArray = range(1, 11);shuffle(\$startArray);//how do I group the first three elements in the array?, array_chunkecho join(', ', \$startArray);  ```

9. Originally Posted by lukeurtnowski
I lloks like after the array is shuffled, the first three elements (1, 2, 3) are grouped together in the array?
Is this ok?
PHP Code:
``` \$startArray = range(1, 11);shuffle(\$startArray);//how do I group the first three elements in the array?, array_chunkecho join(', ', \$startArray);  ```
Give me an example of your expected output.

Are you expecting to just see the first 3 random numbers?

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•