Hex Shifta

<div style="background:#<?php echo hex_shift('c1c2b4',10,'+'); ?>">Shifta</div>

<?php
function hex_shift($hex,$percent = 10,$shift_dir = '-'){
$RGB_values = array();
$new_hex = null;
if(strlen($hex) == 3) if(preg_match('/^([0-9a-f])([0-9a-f])([0-9a-f])/i',$hex)) $hex = preg_replace('/^([0-9a-f])([0-9a-f])([0-9a-f])/i','\1\1\2\2\3\3',$hex);
$RGB_values['R'] = hexdec($hex{0}.$hex{1});
$RGB_values['G'] = hexdec($hex{2}.$hex{3});
$RGB_values['B'] = hexdec($hex{4}.$hex{5});
foreach($RGB_values as $c => $v){
if($shift_dir == '+') $amount = round(((255 - $v) / 100) * $percent) + $v;
else $amount = $v - round(($v / 100) * $percent);
$new_hex .= $current_value = (strlen($decimal_to_hex = dechex($amount)) < 2) ? '0' . $decimal_to_hex : $decimal_to_hex;
}
return $new_hex;
}
?>

Random hex css color

<span style=" <?php mhs_random_hex_color_css() ?>">HI</span>

function mhs_random_hex_color_css(){ echo 'color:#' . sprintf("%02X%02X%02X",mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)) . ';'; }

Random Hex Color

/**

* Get random color hex value

*

* @param integer $max_r Maximum value for the red color

* @param integer $max_g Maximum value for the green color

* @param integer $max_b Maximum value for the blue color

* @return string

*/
function getRandomColorHex($max_r = 255, $max_g = 255, $max_b = 255)

{

// ensure that values are in the range between 0 and 255

if ($max_r > 255) { $max_r = 255; }

if ($max_g > 255) { $max_g = 255; }

if ($max_b > 255) { $max_b = 255; }

if ($max_r < 0) { $max_r = 0; }

if ($max_g < 0) { $max_g = 0; }

if ($max_b < 0) { $max_b = 0; }

// generate and return the random color

echo '#' . dechex(rand(0, 255)) . dechex(rand(0, 255)) . dechex(rand(0, 255));

}