Home / Software / Computer programming / php array
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: php array  (Read 768 times)
thunder708
Topic Starter
Rookie



Posts: 14


« on: February 07, 2010, 04:40:13 PM »

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?
IP logged
thunder708
Topic Starter
Rookie



Posts: 14


« Reply #1 on: February 08, 2010, 09:27:36 AM »

any moderators/admins please delete this thread now please i have resolved the problem myself

thanks you
IP logged
kpac
Web moderator
Hacker



Thanked: 179
Posts: 5,828

Certifications: List
Computer: Specs
Experience: Expert
OS: Windows 7
kpac®

1 1 1
« Reply #2 on: February 08, 2010, 12:38:57 PM »

If you don't mind, please post the solution. It may help someone in the future.
IP logged

thunder708
Topic Starter
Rookie



Posts: 14


« Reply #3 on: February 08, 2010, 12:42:03 PM »

Code: [Select]
<?php
function hex2rgb($hex){



$rgb = array();



$rgb['r'] = hexdec(substr($hex02));



$rgb['g'] = hexdec(substr($hex22));



$rgb['b'] = hexdec(substr($hex42));



return 
$rgb;

}

print_r(hex2rgb('ffffff'));

$colors hex2rgb('ffffff');

echo 
"<br>".$colors['r'];
echo 
"<br>".$colors['g'];
echo 
"<br>".$colors['rb];


?>


IP logged
Pages: [1] - (Top) Print 
Home / Software / Computer programming / php array « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.156 seconds with 20 queries.