note 91753 deleted from function.hexdec by danbrown

From: Date: Wed, 24 Jun 2009 17:18:53 +0000
Subject: note 91753 deleted from function.hexdec by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157428@lists.php.net to get a copy of this message
Note Submitter: Rodrigo Gregrio ---- passe valores HEX para RGB útil para passar cores utilizadas na css em HEX para RGB utilização echo hex2rgb('FFFFFF');// saída 255,255,255 echo hex2rgb('FFFFFF','rgb');// saída array(r=>255,g=>255,b=>255) function hex2rgb($hex, $rgb) { $int = hexdec($hex); switch($rgb) { case "r": return 0xFF & $int >> 0x10; break; case "g": return 0xFF & ($int >> 0x8); break; case "b": return 0xFF & $int; break; case "rgb": return array( "r" => 0xFF & $int >> 0x10, "g" => 0xFF & ($int >> 0x8), "b" => 0xFF & $int ); break; default: $_rgb .= 0xFF & $int >> 0x10; $_rgb .= ','; $_rgb .= 0xFF & ($int >> 0x8); $_rgb .= ','; $_rgb .= 0xFF & $int; return $_rgb; break; } }

« previous php.notes (#157428) next »