Doc #52214 [Opn->Bgs]: Using ampersand not percent for modulus.

From: Date: Wed, 30 Jun 2010 22:35:29 +0000
Subject: Doc #52214 [Opn->Bgs]: Using ampersand not percent for modulus.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4620@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52214&edit=1 ID: 52214 Updated by: degeberg@php.net Reported by: dan dot lugg at yahoo dot ca Summary: Using ampersand not percent for modulus. -Status: Open +Status: Bogus Type: Documentation Problem Package: Documentation problem PHP Version: 5.3.2 New Comment: It's not trying to do modular arithmetic. & is "bitwise and", and the function checks if the last bit is 1, i.e. if it is odd. The example is correct. Previous Comments: ------------------------------------------------------------------------ [2010-07-01 00:23:33] dan dot lugg at yahoo dot ca Description: ------------ It appears that an example in the documentation for array_filter() is performing modulus with an ampersand (&) not percent (%) as it should. function odd($arg){ return($arg & 1); // should be return ($arg % 1); } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52214&edit=1

« previous php.doc.bugs (#4620) next »