PHP functions convert 16 color codes to RGB color values
Use the PHP function to convert 16 forbidden color codes to RGB color values.
/** * Function 16 binary color converted 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, =SUBSTR); $b ($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 PHP converts BR newline characters in HTML to line breaks in text input
- PHP converts consecutive spaces in a string to a space
- PHP converts full-width characters in a string to half-width characters
- JS How to convert the returned string to JSON-formatted data
- PHP uses the Session_set_save_handler () function to save the session to the MySQL database
- How PHP converts an IP address to a real address
- PHP using ziparchive function to realize the compression and decompression of files
- PHP implementation restricts domain names and protects source code from being copied
http://www.bkjia.com/PHPjc/1000763.html www.bkjia.com true http://www.bkjia.com/PHPjc/1000763.html techarticle The PHP function converts a 16-color code into an RGB color value using a PHP function to convert a 16 forbidden color code to an RGB color value. /** * Function 16 binary color converted to RGB color value * Author www.php ...