RGB to HTML

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-21-2008
cjlopesmartins@gmail.com
 
Posts: n/a
Default RGB to HTML

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
#??????

Thanks in advance





Reply With Quote
  #2 (permalink)  
Old 02-21-2008
Rik Wasmus
 
Posts: n/a
Default Re: RGB to HTML

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
Reply With Quote
  #3 (permalink)  
Old 02-21-2008
Toby A Inkster
 
Posts: n/a
Default Re: RGB to HTML

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/
Reply With Quote
  #4 (permalink)  
Old 02-21-2008
Michael Fesser
 
Posts: n/a
Default Re: RGB to HTML

..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
Reply With Quote
  #5 (permalink)  
Old 02-21-2008
pakalk
 
Posts: n/a
Default 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')); ?>

:>
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:19 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0