note 38495 added to function.base-convert
| From: | fiftytoo at buckeyeexpress dot com | Date: | Wed, 24 Dec 2003 05:57:30 +0000 |
| Subject: | note 38495 added to function.base-convert | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62401@lists.php.net to get a copy of this message | ||
I needed a function to invert a hex value, which i used for setting font colors when they were on a
colored background, that way i will get a contrasting color.
Im sure there are other reasons to use this, you decide!!
<?php
function InvertColor($hex) {
return sprintf("%06s",base_convert(($hex ^ 0xFFFFFF),10,16));
};
print '<td bgcolor="BB2222"><font
color="'.InvertColor(0xBB2222).'">Blah</font></td>';
// Prints 44dddd as the font color, which is it's opposite on the color wheel
?>
----
Manual Page -- http://www.php.net/manual/en/function.base-convert.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38495
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38495&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38495&report=yes
Search -- http://master.php.net/manage/user-notes.php