蟋蟀
版主
  
村里巡逻队长
UID 67242
精华
0
积分 2036
帖子 1763
金钱 2036 喜悦币
威望 0
人脉 0
阅读权限 100
注册 2005-12-17 来自 福建
状态 离线
|
这两个函数相同不?我调试了半天感觉好象都有错.
<?php
/** 函数 indexToRgb
* 参数 $clr 索引色
* 返回 rgb数组
* 描述 转化索引色为rgb色
*/
function indexToRgb($clr)
{
$clr=strpos($clr,"#")?substr($clr,1) clr;
$r=hexdec(substr($clr,0,2));
$g=hexdec(substr($clr,2,2));
$b=hexdec(substr($clr,-2));
return array("red"=>$r,"green"=>$g,"blue"=>$b);
}
function index2ToRgb($clr)
{
$clr=strpos($clr,"#")?$substr($clr,1) clr;
$r=($clr>>16) & 0xFF;
$g=($clr>>8) & 0xFF;
$b=$clr & 0xFF;
return array("red"=>hexdec($r),"green"=>hexdec($g),"blue"=>hexdec($b));
}
print_r(indexToRgb("#234556"));
print_r(index2ToRgb("#234556"));
|  吉林php群
27089230 |
|