I am trying to give every string a random color. But all the colors are the same and only change on page load.
Here is my code
<?php
$variable = 'value1, value2, value3, value4, value5';
$colors= array("pink", "light-blue", "indigo", "purple", "orange", "green");
$random_color = $colors[array_rand($colors)];
$arrs = explode(',', $variable);
foreach($arrs as $arr): ?>
<span style="color: <?php echo $random_color; ?>"><?php echo $arr ?></span>
<?php endforeach; ?>
Someone knows how to fix this?