Thanks for Visiting. Please register to Enjoy forum.


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTML to RGB (Convert HTML color code to RGB)
08-02-2010, 05:46 PM
Post: #1
HTML to RGB (Convert HTML color code to RGB)
small function to convert html code to rgb code
Code:
<?php
function html2rgb($color)
{
$return['r']=0;
$return['g']=0;
$return['b']=0;

if($color[0] == '#'){
$color = substr($color, 1);}

if(strlen($color) == 6){
list($r, $g, $b)=array(
    $color[0].$color[1],
    $color[2].$color[3],
    $color[4].$color[5]
        );}

elseif(strlen($color)==3){
list($r, $g, $b)=array(
    $color[0].$color[0],
    $color[1].$color[1],
    $color[2].$color[2]
        );}
else{
return false;}

$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);

$return['r']=$r;
$return['g']=$g;
$return['b']=$b;

return $return;
}
?>
Usage
Code:
<?php
print_r(html2rgb("#ff0000"));
?>
Now you can use some more tweaks in ur php GD images

please help me get this & this scripts. i urgently need them. M ready to pay 20$ each :')
Find all posts by this user
Quote this message in a reply
07-07-2010, 02:29 PM
Post: #2
RE: HTML to RGB (Convert HTML color code to RGB)
I have make project using php so It is very helpful for me to Convert HTML color code to RGB.I will also use this code in my project.I hope it successfully convert HTML color code to RGB.

8gb cf card
Find all posts by this user
Quote this message in a reply
Thank given by VaruN
Post Reply 


Forum Jump: