Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

: four plus zero?
(Example: nine)

The Note You're Voting On

baoquyen804 at gmail dot com
10 years ago
this base function convert string rgb to color
<?php
function rgb_to_color($rgb, $symbols=' '){
$color = '';
$arr = explode($symbols, $rgb);
$count = count($arr);
for(
$i=0; $i<$count; $i++){
$color .= dechex($arr[$i]);
}
return
'#'.$color;
}
echo
rgb_to_color('186 186 18'); // #baba12
echo rgb_to_color('186-186-18', '-'); // #baba12
?>

<< Back to user notes page

To Top