|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52214 Using ampersand not percent for modulus.
Submitted: 2010-07-01 00:23 UTC Modified: 2010-07-01 00:35 UTC
From: dan dot lugg at yahoo dot ca Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dan dot lugg at yahoo dot ca
New email:
PHP Version: OS:


 [2010-07-01 00:23 UTC] dan dot lugg at yahoo dot ca
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);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-01 00:35 UTC]
-Status: Open +Status: Bogus
 [2010-07-01 00:35 UTC]
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.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Aug 02 19:01:25 2021 UTC