Created
October 6, 2016 15:43
-
-
Save YurePereira/10b82cb9e3d3a4e18fcac023828b564f to your computer and use it in GitHub Desktop.
Converte código HTML hexadecimal para decimal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Converte código HTML hexadecimal para decimal. | |
| * | |
| * @param $code String código HTML hexadecimal. | |
| * | |
| * @return Array | |
| */ | |
| function hexaHtmlToDecimal($code) { | |
| if (strlen($code) == 7) { | |
| $code = str_replace('#', '', $code); | |
| $codeR = substr($code, 0, 2); | |
| $codeG = substr($code, 2, 2); | |
| $codeB = substr($code, 4, 2); | |
| return array( | |
| 'r' => hexdec($codeR), | |
| 'g' => hexdec($codeG), | |
| 'b' => hexdec($codeB) | |
| ); | |
| } else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment