Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Get color code from string

function getColour($seed, $rgbArray = false) {
    $hash = md5($seed);
    $r = hexdec(substr($hash, 0, 2));
    $g = hexdec(substr($hash, 2, 2));
    $b = hexdec(substr($hash, 4, 2));
    if ($rgbArray) {
        return array('R' => $r, 'G' => $g, 'B' => $b);
    }
    $highR = $r + 10;
    $highG = $g + 10;
    $highB = $b + 10;
    $main = '#' . str_pad(dechex($r), 2, '0', STR_PAD_LEFT)
        . str_pad(dechex($g), 2, '0', STR_PAD_LEFT)
        . str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
    $highlight = '#' . dechex($highR) . dechex($highG) . dechex($highB);
    return array('main' => $main, 'highlight' => $highlight);
}

$t = getColour('Assigned');
Comment

PREVIOUS NEXT
Code Example
Php :: php artisan migrate not working 
Php :: filemtime($current_file_name); 
Php :: add another field in existing migration laravel 
Php :: how to get value of textarea in php 
Php :: php inline if null check 
Php :: php why " " not new line 
Php :: how to check exist in array in rule validation laravel 
Php :: integer nullable laravel 
Php :: default null migration laravel 
Php :: array push foreach php 
Php :: pass php variable in onclick function 
Php :: carbon date minus days 
Php :: convert text to slug php 
Php :: diff for seconds laravel carbon 
Php :: how to run a specific migration in laravel 
Php :: How to insert time in table using CodeIgniter 
Php :: twig ternary 
Php :: confirm password validation in laravel 
Php :: laravel model tree 
Php :: laravel orderby with relation 
Php :: wp enqueue style for style.css 
Php :: how to return with open model popup in laravel 
Php :: laravel date default now 
Php :: date to string in php 
Php :: php find text in variable 
Php :: laravel collection random 
Php :: change date format php 
Php :: php empty 
Php :: sort laravel eloquent 
Php :: laravel where like 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =