

InterviewSolution
Saved Bookmarks
1. |
Solve : php array? |
Answer» HI i have this function to convert hex to rgb values Code: [Select]<? function hex2rgb($hex){ $rgb = array(); $rgb['r'] = hexdec(substr($hex, 0, 2)); $rgb['g'] = hexdec(substr($hex, 2, 2)); $rgb['b'] = hexdec(substr($hex, 4, 2)); return $rgb; } print_r(hex2rgb('ffffff')); ?> i can SHOW the contents of the array but i am sturggling to use the contents - the atcualy r g b values. any help?any moderators/admins please delete this THREAD now please i have resolved the problem myself thanks youIf you don't mind, please POST the solution. It may help someone in the future.Code: [Select]<?php functionhex2rgb($hex){ $rgb=array(); $rgb['r']=hexdec(substr($hex,0,2)); $rgb['g']=hexdec(substr($hex,2,2)); $rgb['b']=hexdec(substr($hex,4,2)); return$rgb; } print_r(hex2rgb('ffffff')); $COLORS=hex2rgb('ffffff'); echo"<br>".$colors['r']; echo"<br>".$colors['g']; echo"<br>".$colors['rb]; ?> |
|