php颜色转换函数hex-rgb
a target=_blank href=http://list.qq.com/cgi-bin/qf_invite?id=08f814f703c7b4139f32b06cc2f7c0c1fd1b46f032c64622 rel=nofollow/a a href=http://qita.in/bMv target=_blank rel=nofollowimg alt=填写您的邮件地址,订阅我们的精彩内容:

一个很使用的php颜色转换函数,用于将hex表示的颜色值转换为rgb格式。例如:#dfdfdf转换成(239,239,239)
<?php //http://blog.ddian.cn function hex2rgb( $colour ) { if ( $colour[0] == '#' ) { $colour = substr( $colour, 1 ); } if ( strlen( $colour ) == 6 ) { list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] ); } elseif ( strlen( $colour ) == 3 ) { list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] ); } else { return false; } $r = hexdec( $r ); $g = hexdec( $g ); $b = hexdec( $b ); return array( 'red' => $r, 'green' => $g, 'blue' => $b ); } ?>
精彩图集
精彩文章