Trying to get an item randomly from array($colors
) without having two same colors next to each other.
<div class="list">
<?php
foreach ($team as $member):
$index++;
?>
<div class="member location-<?php echo strtolower($member->location); ?>">
<a style="background: #FFF url('<?php echo $member->profileImage; ?>') no-repeat;" data-start-date="<?php echo $member->startDate; ?>">
<?php shuffle($colors); // Shuffle the array ?>
<span class="name" style="background-color: #<?php echo array_pop($colors)->color; ?>"><?php echo $member->name; ?></span>
<span class="job-title"><span class="text"><?php echo $member->jobTitle; ?></span></span>
</a>
</div>
<?php endforeach; ?>
</div>
Right now I have some cases when I'm getting a color next to each other.
How do I get each time a different color? I'd like to mention that count($team) > count($colors) (is greater).
Aucun commentaire:
Enregistrer un commentaire