UNKNOWN //************************************** // Name: Converting hex color code to numeric // Description:/* * Author : Rajan Maharjan * Website : http://www.rajanmaharjan.com.np * Created Date : 26th September, 2010 * Description : This function gives the numeric value for the hex color code. * @param : 99ccff | 99CCFF | 9cf * example : hexColor2Numeric(“9cf”); */ // By: Maharjan Rajan // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.2807/lngWId.8/qx/vb/scripts/ShowCode.htm //for details. //************************************** $arrayStoreColor=hexColor2Numeric(“99cacff”); print_r($arrayStoreColor); function hexColor2Numeric($colorHex){ if(strlen($colorHex)==6 || strlen($colorHex)==3){ $arrayKey=array(“red”,”green”,”blue”); $arrayStoreColor=array(); for($i=0;$i<3;$i++){ if(strlen($colorHex)==6){ $rgb=substr($colorHex,$i*2,2); $arrayStoreColor[$arrayKey[$i]]=hexdec(substr($rgb,0,1))*16+hexdec(substr($rgb,1,1)); } else{ $arrayStoreColor[$arrayKey[$i]]=hexdec($rgb)*16+hexdec($rgb); $rgb=substr($colorHex,$i,1); } } } else $arrayStoreColor="Invalid color code or invalid code length. Code must be in format FC9 or FFCC99"; return $arrayStoreColor; }