note 84192 added to language.operators.bitwise

From: Date: Wed, 02 Jul 2008 19:32:14 +0000
Subject: note 84192 added to language.operators.bitwise
Groups: php.notes 
Request: Send a blank email to php-notes+get-141084@lists.php.net to get a copy of this message
here's a fast alternative to compute the xor-value of two bitstrings of an arbitrary (but same) length. <?php /** * xor-op for bitstrings of arbitrary length * bitstrings must have same length * * @param string $o1 * @param string $o2 * @return string */ function bitxor($o1, $o2) { $xorWidth = PHP_INT_SIZE*8; // split $o1 = str_split($o1, $xorWidth); $o2 = str_split($o2, $xorWidth); $res = ''; $runs = count($o1); for($i=0;$i<$runs;$i++) $res .= decbin(bindec($o1[$i]) ^ bindec($o2[$i])); return $res; } ?> ---- Server IP: 212.124.37.9 Probable Submitter: 85.179.233.161 ---- Manual Page -- http://www.php.net/manual/en/language.operators.bitwise.php Edit -- https://master.php.net/note/edit/84192 Del: integrated -- https://master.php.net/note/delete/84192/integrated Del: useless -- https://master.php.net/note/delete/84192/useless Del: bad code -- https://master.php.net/note/delete/84192/bad+code Del: spam -- https://master.php.net/note/delete/84192/spam Del: non-english -- https://master.php.net/note/delete/84192/non-english Del: in docs -- https://master.php.net/note/delete/84192/in+docs Del: other reasons-- https://master.php.net/note/delete/84192 Reject -- https://master.php.net/note/reject/84192 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141084) next »