note 70819 deleted from language.operators.bitwise by tularis

From: Date: Tue, 15 May 2007 15:49:30 +0000
Subject: note 70819 deleted from language.operators.bitwise by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126617@lists.php.net to get a copy of this message
Note Submitter: nicolaas francken ---- The function below can show you which bits are on. In this way, you can store eight Boolean values in a single number (from 0 to 255): echo '<br />the number you provided is '.$_GET["j"].'.'; for($i = 1; $i < 9; $i++) { echo '<br /> &nbsp; bit '.$i.' is '.bitcheck($i, $_GET["j"]); } function bitcheck($a, $b) { if((pow(2,($a-1))) & ($b)) { return "ON"; } else { return "OFF"; } }

« previous php.notes (#126617) next »