RE: [PHP] Bitwise solution?
| From: | Boget, Chris | Date: | Fri, 02 Mar 2001 14:58:25 +0000 |
| Subject: | RE: [PHP] Bitwise solution? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-42345@lists.php.net to get a copy of this message | ||
> > I have 2 values. The first is a constant while the second is not.
> Is the first value a numerical value (real/integer?) or a
> string value?
String.
This is what I've come up with and it seems to work pretty ok.
What do you guys think?
(test code to illustrate a point; other than the XORing, not
what I'm actually going to do with the "live" code)
<script language="php">
$uniqueArray = array();
for( $i = 0; $i <= 100; $i++ ) {
$certnum = date( "U" ); // what the second variable is always set
to
if( $certnum == $lastCertNum ) {
sleep( 1 );
}
$uid = ( $uid == "nsa000" ) ? "mdb000" : "nsa000"; // sample
first
variable
$uniqueNum = ( hexdec( $uid ) ^ $certnum );
echo "$uid ^ $certnum = $uniqueNum<br>\n";
if( in_array( $uniqueNum, $uniqueArray )) {
echo "Not a unique number!<br><br>\n";
}
$uniqueArray[] = $uniqueNum;
flush();
$lastCertNum = $certnum;
}
</script>
Chris