This is a discussion on RGB to HTML within the PHP Language forums, part of the PHP Programming Forums category; Hi Please help I have this mysql table field with a RGB value like 120-10-200 and I nead ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Thu, 21 Feb 2008 11:24:24 +0100, cjlopesmartins@gmail.com
<cjlopesmartins@gmail.com> wrote: > Hi > > Please help > > 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 > #?????? If you need in in css, it can perfectly handle rgb(123,123,123) values, however, it's a simple matter of explode(), dechex() the items, and implode() or concatenate. -- Rik Wasmus |
|
|||
|
cjlopesmartins@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); ?> -- Toby A Inkster BSc (Hons) ARCS [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux] [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 22 days, 17:55.] Bottled Water http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/ |
|
|||
|
..oO(Toby A Inkster)
>cjlopesmartins@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)); ?> SCNR Micha |
|
|||
|
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')); ?> :> |