Page 1 of 1

PHP Random FONT Color Function

New postPosted: Sat Dec 28, 2013 3:50 pm
by Cat
Code: [Select all] [Expand/Collapse] [Download] (Untitled)
<?php
error_reporting(0);
function rcolor() {
srand((double)microtime()*10000000);
$rand = (rand(30,170));
return sprintf("%02X","$rand");
}

function rand_color($string) {
$array = explode(" ",$string);
$j = count($array);
for ($i=0;$i<$j;$i++) {
$return .= '<font color="#'.rcolor().rcolor().rcolor().'">'.$array[$i].' </font>'; }
return $return;
}
?>

<html>
<body bgcolor="#FFFFFF">
<h3>
<?php echo rand_color("This is an example of my rand_color() function on a long string"); ?>
</h3>
</body>
</html>


Demo!


Anyone who wishes to make additions or changes to this tutorial email them to webmaster@linuxguruz.com