By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

RGB to HTML

P: n/a
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

Feb 21 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Thu, 21 Feb 2008 11:24:24 +0100, cj************@gmail.com
<cj************@gmail.comwrote:
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
Feb 21 '08 #2

P: n/a
cj************@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/
Feb 21 '08 #3

P: n/a
..oO(Toby A Inkster)
>cj************@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
Feb 21 '08 #4

P: n/a
On 21 Lut, 18:13, Michael Fesser <neti...@gmx.dewrote:
.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')); ?>

:>
Feb 21 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.