<?php
function swift_rgb2hex($rgb,$hash=true) {
if($rgb == NULL){
return 'none';
}
if($hash)
$hex = '#';
$temp = explode('(',$rgb);
echo $temp;
if(!is_array($temp) || count($temp)<=1){
return $rgb;
}
$rgb = $temp[1];
$temp = explode(')',$rgb);
$rgb = $temp[0];
$rgb = explode(',',$rgb);
$hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
return $hex;
}
/*
echo swift_rgb2hex('rgba(0,0,0)');
echo swift_rgb2hex('rgba(255,255,0)');
echo swift_rgb2hex('boom');
echo swift_rgb2hex('FFFFFF');
*/
echo swift_rgb2hex('rgba(0,0,0)');
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Warning: Array to string conversion in /in/lvhfv on line 11
Array#000000
- Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
- Notice: Array to string conversion in /in/lvhfv on line 11
Array#000000
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 7.3.32 - 7.3.33
- Array#000000
preferences:
257.73 ms | 403 KiB | 314 Q