site-accueil-insa/assets/fonts/color.php
2022-06-20 18:54:57 +02:00

18 lines
No EOL
415 B
PHP

<?php
function colored_text($str) {
$cl = ["red", "blue", "green", "orange", "grey", "brown", "purple"];
$str_out = "";
$ant_color = "";
for($i=0; $i<=strlen($str)-1 ;$i++) {
$color = $cl[rand(0, 6)];
while($color == $ant_color) {
$color = $cl[rand(0, 6)];
}
$ant_color = $color;
$str_out = $str_out."<font color='".$color."'>".$str[$i]."</font>";
}
return "<strong>".$str_out."</strong>";
}
?>