note 57622 added to function.hexdec

From: Date: Sun, 09 Oct 2005 05:53:15 +0000
Subject: note 57622 added to function.hexdec
Groups: php.notes 
Request: Send a blank email to php-notes+get-96708@lists.php.net to get a copy of this message
I needed to get the opposite colors so my website would be soft on the eyes. <?php function OppositeHex($color) { $r = dechex(255 - hexdec(substr($color,0,2))); $r = (strlen($r) > 1) ? $r : '0'.$r; $g = dechex(255 - hexdec(substr($color,2,2))); $g = (strlen($g) > 1) ? $g : '0'.$g; $b = dechex(255 - hexdec(substr($color,4,2))); $b = (strlen($b) > 1) ? $b : '0'.$b; return $r.$g.$b; } //Example $color = '000000'; echo 'The opposite of #'.$color.' is #'.OppositeHex($color).'; ?> ---- Manual Page -- http://www.php.net/manual/en/function.hexdec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57622 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57622&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57622&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96708) next »