The php function converts the hexadecimal color code to an RGB color value. The php function converts the hexadecimal color code to the RGB color value. The php function is used to convert the 16 forbidden color code to the RGB color value. * ** Convert the base-16 color to an RGB color value * the authorwww. php function converts the base-16 color code to an RGB color value.
Use the php function to convert the 16 forbidden color code to an RGB color value.
/*** Function hexadecimal color conversion to RGB color value * author www.phpernote.com */function hex2rgb ($ hexColor) {$ color = str_replace ('#','', $ hexColor); if (strlen ($ color)> 3) {$ rgb = array ('R' => hexdec (substr ($ color, 0, 2 )), 'G' => hexdec (substr ($ color, 2, 2), 'B' => hexdec (substr ($ color, 4, 2 )));} else {$ color = str_replace ('#', '', $ hexColor); $ r = substr ($ color, 0, 1 ). substr ($ color, 0, 1); $ g = substr ($ color, 1, 1 ). substr ($ color, 1, 1); $ B = substr ($ color, 2, 1 ). substr ($ color, 2, 1); $ rgb = array ('R' => hexdec ($ r), 'G' => hexdec ($ g ), 'B' => hexdec ($ B);} return $ rgb ;}
For example:
Print_r (hex2rgb ('# F03'); // output: Array ([r] => 255 [g] => 0 [B] => 51)
Articles you may be interested in
- How does php convert the br line breaks in html to line breaks in text input?
- Php converts multiple consecutive spaces in a string into one.
- Php converts all-round characters in a string to half-width characters.
- How does js convert the returned string to json format data?
- Php uses the session_set_save_handler () function to save the session to the MySQL database.
- Php to convert an IP address to a real address
- Php uses the ZipArchive function to compress and decompress files.
- PHP restricts domain names to protect source code from being copied
The http://www.bkjia.com/PHPjc/1000763.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1000763.htmlTechArticlephp function converts the hexadecimal color code to the RGB color value using the php function to convert the 16 forbidden color code to the RGB color value. /*** Function hexadecimal color conversion to RGB color value * author www. php...