callback function return return($var & 1)?

前端 未结 8 2107
灰色年华
灰色年华 2020-12-05 22:07

I have read the PHP Manuel about array_filter



        
8条回答
  •  感情败类
    2020-12-05 22:50

    & 
    

    it's the bitwise operator. It does the AND with the corrispondent bit of $var and 1

    Basically it test the last bit of $var to see if the number is even or odd

    Example with $var binary being 000110 and 1

    000110 &
         1
    ------
         0
    

    0 (false) in this case is returned so the number is even, and your function returns false accordingly

提交回复
热议问题