Published in: PHP
Any comments/suggestions are always welcome.
Expand |
Embed | Plain Text
<?php /** * Inverses a provided hex color. If you pass a hex string with a * hash(#), the function will return a string with a hash prepended * @param string $color Hex color to flip * @return string Reversed hex color * @author Koncept * * Last Update: 2008-10-05 */ function inverseHex( $color ) { $prependHash = FALSE; $prependHash = TRUE; } case 3: break; case 6: break; default: trigger_error("Invalid hex length ($len). Must be a minimum length of (3) or maxium of (6) characters", E_USER_ERROR); } } return ($prependHash?'#':NULL).$r.$g.$b; } // Demo ?>
Comments
Subscribe to comments
You need to login to post a comment.
Shouldn't this: case 3: $color=preg_replace("/(.)(.)(.)/","\1\1\2\2\3\3",$color); case 6:
actually be this: case 3: case 6: $color=preg_replace("/(.)(.)(.)/","\1\1\2\2\3\3",$color);
Guess my formatting wasn't correct, I was asking: Shouldn't this:
case 3: $color=preg_replace("/(.)(.)(.)/","\1\1\2\2\3\3",$color); case 6:actually be this:
case 3: case 6: $color=preg_replace("/(.)(.)(.)/","\1\1\2\2\3\3",$color);You caught something there... There should be a break after case 3. Corrected.