Re: RGB to HTML
On 21 Lut, 18:13, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Toby A Inkster)
>
> >cjlopesmart...@gmail.com wrote:
>
> >> I have this mysql table field with a RGB value like 120-10-200 and I
> >> nead this php function to convert this value into html color #??????
>
> ><?php
> > $rgb = '120-10-200';
> > list ($r, $g, $b) = explode('-', $rgb);
> > $hex = sprintf('#%02x%02x%02x', $r, $g, $b);
> >?>
>
> <?php
> $rgb = '120-10-200';
> $hex = vsprintf('#%02x%02x%02x', explode('-', $rgb));
> ?>
>
<?php $hex = vsprintf('#%02x%02x%02x', explode('-', '120-10-200')); ?>
:>
|