|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
47 + 5 = ?
Subscribe to this entry?

 [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-2020 The PHP Group
All rights reserved.
Last updated: Sat Mar 28 19:01:27 2020 UTC