";@H_301_3@echo RGBToHex ( "rgb(247,247,218)" )?>@H_301_3@PHP
function HexToRGB($colour) {@H_301_3@ if ($colour [0] == '#') {@H_301_3@ $colour = substr ( $colour,1 );@H_301_3@ }@H_301_3@ if (strlen ( $colour ) == 6) {@H_301_3@ list ( $r,$g,$b ) = array (@H_301_3@ $colour [0] . $colour [1],@H_301_3@ $colour [2] . $colour [3],@H_301_3@ $colour [4] . $colour [5] @H_301_3@ );@H_301_3@ } elseif (strlen ( $colour ) == 3) {@H_301_3@ list ( $r,$b ) = array (@H_301_3@ $colour [0] . $colour [0],@H_301_3@ $colour [1] . $colour [1],@H_301_3@ $colour [2] . $colour [2] @H_301_3@ );@H_301_3@ } else {@H_301_3@ return false;@H_301_3@ }@H_301_3@ $r = hexdec ( $r );@H_301_3@ $g = hexdec ( $g );@H_301_3@ $b = hexdec ( $b );@H_301_3@ return array (@H_301_3@ 'red' => $r,@H_301_3@ 'green' => $g,@H_301_3@ 'blue' => $b @H_301_3@ );@H_301_3@}@H_301_3@function RGBToHex($rgb) {@H_301_3@ $regexp = "/^rgb\(([0-9]{0,3})\,\s*([0-9]{0,3})\)/";@H_301_3@ $re = preg_match ( $regexp,$rgb,$match );@H_301_3@ $re = array_shift ( $match );@H_301_3@ $hexColor = "#";@H_301_3@ $hex = array (@H_301_3@ '0',@H_301_3@ '1',@H_301_3@ '2',@H_301_3@ '3',@H_301_3@ '4',@H_301_3@ '5',@H_301_3@ '6',@H_301_3@ '7',@H_301_3@ '8',@H_301_3@ '9',@H_301_3@ 'A',@H_301_3@ 'B',@H_301_3@ 'C',@H_301_3@ 'D',@H_301_3@ 'E',@H_301_3@ 'F' @H_301_3@ );@H_301_3@ for($i = 0; $i < 3; $i ++) {@H_301_3@ $r = null;@H_301_3@ $c = $match [$i];@H_301_3@ $hexAr = array (); while ( $c > 16 ) {@H_301_3@ $r = $c % 16;@H_301_3@ $c = ($c / 16) >> 0;@H_301_3@ array_push ( $hexAr,$hex [$r] );@H_301_3@ }@H_301_3@ array_push ( $hexAr,$hex [$c] ); $ret = array_reverse ( $hexAr );@H_301_3@ $item = implode ( '',$ret );@H_301_3@ $item = str_pad ( $item,2,'0',STR_PAD_LEFT );@H_301_3@ $hexColor .= $item;@H_301_3@ }@H_301_3@ return $hexColor;@H_301_3@}@H_301_3@?>@H_301_3@