Skip to content

Instantly share code, notes, and snippets.

@bobbykjack
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save bobbykjack/d18f7cd52549fce08856 to your computer and use it in GitHub Desktop.

Select an option

Save bobbykjack/d18f7cd52549fce08856 to your computer and use it in GitHub Desktop.
Tiny script to convert CSS rgb color syntax into hexadecimal
if (preg_match('/^rgb\(([0-9]+),\s*([0-9]+),\s*([0-9]+)\)$/', $_GET['rgb'], $m) && count($m) == 4)
{
echo '#'.join('', array_map(function($n) { return str_pad(dechex($n), 2, '0', STR_PAD_LEFT); }, array_slice($m, 1)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment