callback function return return($var & 1)?

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

I have read the PHP Manuel about array_filter



        
8条回答
  •  忘掉有多难
    2020-12-05 22:44

    It is performing a bitwise AND with $var and 1. Since 1 only has the last bit set, $var & 1 will only be true if the last bit is set in $var. And since even numbers never have the last bit set, if the AND is true the number must be odd.

提交回复
热议问题