If you like me have some trouble understanding example #1 due to the bitwise operator (&) used, here is an explanation.
The part in question is this callback function:
<?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}
?>
If given an integer this function returns the integer 1 if $var is odd and the integer 0 if $var is even.
The single ampersand, &, is the bitwise AND operator. The way it works is that it takes the binary representation of the two arguments and compare them bit for bit using AND. If $var = 45, then since 45 in binary is 101101 the operation looks like this:
45 in binary: 101101
1 in binary: 000001
------
result: 000001
Only if the last bit in the binary representation of $var is changed to zero (meaning that the value is even) will the result change to 000000, which is the representation of zero.