{"id":752,"date":"2015-08-21T11:20:56","date_gmt":"2015-08-21T11:20:56","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=752"},"modified":"2016-04-22T17:53:24","modified_gmt":"2016-04-22T17:53:24","slug":"convert-color-hex-to-rgb-and-rgb-to-hex-using-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/","title":{"rendered":"Convert Color Hex to RGB and RGB to Hex using PHP"},"content":{"rendered":"<p>This article will explain how to convert color code from HEX to RGB or HEX to RGB using PHP. We have created a PHP function for converting the color code to RGB or HEX. <code>rgb2hex2rgb()<\/code> function makes color conversion simple.<\/p>\n<h2>Parameter:<\/h2>\n<p><code>rgb2hex2rgb()<\/code> function accept one parameter (<code>$color<\/code>) with two types of value RGB or HEX.<\/p>\n<ul>\n<li>\n    <b><code>$color<\/code> =><\/b> Required, from which you want to convert.<\/p>\n<ul>\n<li><b>RGB =><\/b> 255,255,255 or 255 255 255 or 255.255.255<\/li>\n<li><b>HEX =><\/b> #FFFFFF or FFFFFF<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Return Value:<\/h2>\n<p>Returns RGB format color code as an array if Hex color code is passed into <code>$color<\/code> parameter. Returns HEX format color code as a string if RGB color code is passed into <code>$color<\/code> parameter.<\/p>\n<ul>\n<li><b>RGB =><\/b> Array ( [r] => 255 [g] => 255 [b] => 255 )<\/li>\n<li><b>HEX =><\/b> #FFFFFF<\/li>\n<\/ul>\n<h2><code>rgb2hex2rgb()<\/code> function is given below:<\/h2>\n<pre><span style=\"color: #FF8000\">\/**<br \/>*<br \/>*&nbsp;Author:&nbsp;CodexWorld<br \/>*&nbsp;Author&nbsp;URI:&nbsp;http:\/\/www.codexworld.com<br \/>*&nbsp;Function&nbsp;Name:&nbsp;rgb2hex2rgb()<br \/>*&nbsp;$color&nbsp;=&gt;&nbsp;HEX&nbsp;or&nbsp;RGB<br \/>*&nbsp;Returns&nbsp;RGB&nbsp;or&nbsp;HEX&nbsp;color&nbsp;format&nbsp;depending&nbsp;on&nbsp;given&nbsp;value.<br \/>*<br \/>**\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">rgb2hex2rgb<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">){&nbsp;<br \/>&nbsp;&nbsp;&nbsp;if(!<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">)&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$color&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">trim<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">);&nbsp;<br \/>&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;&nbsp;<br \/>&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">preg_match<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"\/^[0-9ABCDEFabcdef\\#]+$\/i\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">)){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$hex&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">str_replace<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'#'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">)&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">strlen<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">)&nbsp;==&nbsp;<\/span><span style=\"color: #0000BB\">3<\/span><span style=\"color: #007700\">):<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'r'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">hexdec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'g'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">hexdec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'b'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">hexdec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'r'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">hexdec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'g'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">hexdec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'b'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">hexdec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">substr<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$hex<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">4<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;}elseif&nbsp;(<\/span><span style=\"color: #0000BB\">preg_match<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"\/^[0-9]+(,|&nbsp;|.)+[0-9]+(,|&nbsp;|.)+[0-9]+$\/i\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">)){&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$rgbstr&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">str_replace<\/span><span style=\"color: #007700\">(array(<\/span><span style=\"color: #DD0000\">','<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'.'<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #DD0000\">':'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$color<\/span><span style=\"color: #007700\">);&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$rgbarr&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">explode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\":\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$rgbstr<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'#'<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #0000BB\">str_pad<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">dechex<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$rgbarr<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]),&nbsp;<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">\"0\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">STR_PAD_LEFT<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #0000BB\">str_pad<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">dechex<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$rgbarr<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">]),&nbsp;<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">\"0\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">STR_PAD_LEFT<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #0000BB\">str_pad<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">dechex<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$rgbarr<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">]),&nbsp;<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">\"0\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">STR_PAD_LEFT<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">strtoupper<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">);&nbsp;<br \/>&nbsp;&nbsp;&nbsp;}else{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">;&nbsp;<br \/>}&nbsp;<\/span><\/pre>\n<h2>Uses:<\/h2>\n<p>Use <code>rgb2hex2rgb()<\/code> function like the following.<\/p>\n<pre><span style=\"color: #0000BB\">$hexString&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">rgb2hex2rgb<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'255,255,255'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$rgbArray&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">rgb2hex2rgb<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'#FFFFFF'<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article will explain how to convert color code from HEX to RGB or HEX to RGB using PHP. We have created a PHP function for converting the color code to RGB or HEX. rgb2hex2rgb() <\/p>\n","protected":false},"author":1,"featured_media":753,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[49,47,14,48],"class_list":["post-752","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-color","tag-hex","tag-php","tag-rgb","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Convert Color Hex to RGB and RGB to Hex using PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"Learn how to convert color from Hex to RGB and RGB to Hex using PHP. Using of rgb2hex2rgb() php function you can easily convert color to RGB or HEX format.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert Color Hex to RGB and RGB to Hex using PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Learn how to convert color from Hex to RGB and RGB to Hex using PHP. Using of rgb2hex2rgb() php function you can easily convert color to RGB or HEX format.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-08-21T11:20:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-04-22T17:53:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"722\" \/>\n\t<meta property=\"og:image:height\" content=\"443\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Convert Color Hex to RGB and RGB to Hex using PHP\",\"datePublished\":\"2015-08-21T11:20:56+00:00\",\"dateModified\":\"2016-04-22T17:53:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/\"},\"wordCount\":128,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png\",\"keywords\":[\"Color\",\"HEX\",\"PHP\",\"RGB\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/\",\"name\":\"Convert Color Hex to RGB and RGB to Hex using PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png\",\"datePublished\":\"2015-08-21T11:20:56+00:00\",\"dateModified\":\"2016-04-22T17:53:24+00:00\",\"description\":\"Learn how to convert color from Hex to RGB and RGB to Hex using PHP. Using of rgb2hex2rgb() php function you can easily convert color to RGB or HEX format.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png\",\"width\":722,\"height\":443,\"caption\":\"convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convert Color Hex to RGB and RGB to Hex using PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Convert Color Hex to RGB and RGB to Hex using PHP - CodexWorld","description":"Learn how to convert color from Hex to RGB and RGB to Hex using PHP. Using of rgb2hex2rgb() php function you can easily convert color to RGB or HEX format.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/","og_locale":"en_US","og_type":"article","og_title":"Convert Color Hex to RGB and RGB to Hex using PHP - CodexWorld","og_description":"Learn how to convert color from Hex to RGB and RGB to Hex using PHP. Using of rgb2hex2rgb() php function you can easily convert color to RGB or HEX format.","og_url":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-08-21T11:20:56+00:00","article_modified_time":"2016-04-22T17:53:24+00:00","og_image":[{"width":722,"height":443,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Convert Color Hex to RGB and RGB to Hex using PHP","datePublished":"2015-08-21T11:20:56+00:00","dateModified":"2016-04-22T17:53:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/"},"wordCount":128,"commentCount":2,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png","keywords":["Color","HEX","PHP","RGB"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/","url":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/","name":"Convert Color Hex to RGB and RGB to Hex using PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png","datePublished":"2015-08-21T11:20:56+00:00","dateModified":"2016-04-22T17:53:24+00:00","description":"Learn how to convert color from Hex to RGB and RGB to Hex using PHP. Using of rgb2hex2rgb() php function you can easily convert color to RGB or HEX format.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png","width":722,"height":443,"caption":"convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Convert Color Hex to RGB and RGB to Hex using PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/08\/convert-color-hex-to-rgb-and-rgb-to-hex-using-php-by-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-c8","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=752"}],"version-history":[{"count":2,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/752\/revisions"}],"predecessor-version":[{"id":755,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/752\/revisions\/755"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/753"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}