Search code examples
phpcolorshexrgb

Convert hex color to RGB values in PHP


What would be a good way to convert hex color values like #ffffff into the single RGB values 255 255 255 using PHP?


Solution

  • Check out PHP's hexdec() and dechex() functions: http://php.net/manual/en/function.hexdec.php

    Example:

    $value = hexdec('ff'); // $value = 255