Jump to content

Re randomize if its taken.


b1011

Recommended Posts

I have the following script:

$color=rand(0,9);

switch ($color){

case 0: $cc="#CCFFCC"; break;

case 1: $cc="#CC6600"; break;

case 2: $cc="#0000CC"; break;

case 3: $cc="#CC00FF"; break;

case 4: $cc="#00CC66"; break;

case 5: $cc="#CCCC00"; break;

case 6: $cc="#616D7E"; break;

case 7: $cc="#25383C"; break;

case 8: $cc="#3BB9FF"; break;

case 9: $cc="#9E7BFF"; break;

 

}

 

witch goes to 34 outcomes.

 

How can i make it rerandomize if it was already made? (this was in a while statement)

Can i set up an array with the current colors? But how can i check if data exits in an array.

Link to comment
https://forums.phpfreaks.com/topic/62558-re-randomize-if-its-taken/
Share on other sites

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.