views:

135

answers:

3

I want PHP to randomly create a multi-dimensional array by picking a vast amount of items out of predefined lists for n times, but never with 2 times the same.

Let me put that to human words in a real-life example: i want to write a list of vegetables and meat and i want php to make a menu for me, with every day something else then yesterday.

I tried and all i got was the scrambling but there were always doubles :s

+2  A: 

Try the shuffle function http://us2.php.net/manual/en/function.shuffle.php

falomir
A: 

Random != unique

You need to either:

a) create a list containing every possible combination and then randomly select and remove one

or

b) store your results so your random selection can be compared to previous selections.

webbiedave
I have already tried the second option you suggested, but i can't figure out how to compare the selections.
BRUL
A: 

Use either array_rand() or shuffle().

QAD