I want to create a sequence of DIV
, but I want every DIV
to have in its background-color
a random color previously known as black, yellow and green, but I do not want these colors to repeat one after another.
Type: yellow > > yellow > > black > > green > > black
I want something like this to happen: yellow > > black > > yellow > > green > > black
I currently use this code to generate random colors for background-color
, but this code repeats colors one after another, since the random color is generated on the refresh of the page.
<?php
$cor = array();
$cor[1] = "#CFF";
$cor[2] = "#9FF";
$cor[3] = "#600";
$cor[4] = "#FF0";
$cor[5] = "#C69";
$cor[6] = "#0F0";
$contador = count($cor);
$aleatorio = rand(1,$contador);
?>
<style>
div{margin-left:15px; width:100px; height:100px; float:left}
</style>
<div style="background-color:<?php echo $cor[$aleatorio] ?>"></div>
<div style="background-color:<?php echo $cor[$aleatorio] ?>"></div>
<div style="background-color:<?php echo $cor[$aleatorio] ?>"></div>
<div style="background-color:<?php echo $cor[$aleatorio] ?>"></div>
<div style="background-color:<?php echo $cor[$aleatorio] ?>"></div>
<div style="background-color:<?php echo $cor[$aleatorio] ?>"></div>
In case my problem is not repeat the colors, but repeat the same color one after another. So I cited the above yellow > > > > > > > > > green & quot; black & quot; pattern, in which case equal colors repeat one after another. The colors may even repeat INVERTER times, but I do not want them to repeat one after another, I want something like: :: Yellow > > black > > Yellow > > black