$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
print_r(array_filter($array1, "odd"));
function odd($var)
{
// returns whether the input integer is odd//
return($var & 1);
}
In the return value what do &
operator ?? how it return odd number
The bitwise AND operator is a single ampersand: & . It is just a representation of AND which does its work on the bits of the operands rather than the truth value of the operands. Bitwise binary AND performs logical conjunction (shown in the table above) of the bits in each position of a number in its binary form.
Description. The bitwise AND operator in C++ is a single ampersand & , used between two other integer expressions. Bitwise AND operates on each bit position of the surrounding expressions independently, according to this rule: if both input bits are 1, the resulting output is 1, otherwise the output is 0.
The single AND operator (&) is known as the Bitwise AND operator. It operates on a single bit. It takes two operands. A bit in the result is 1 if and only if both of the corresponding bits in the operands are 1. The result of the operator may be any number.
The ampersand is the address of operator. It returns the memory location of a variable and that's the only way it's used, prefixed to a variable like the engine on a train. The variable doesn't even have to be initialized, just declared.
It is bitwise operator AND.
For example, ($a & $b)
evaluates both $a
and $b
is turned "on" (i.e. equal to 1)
See this: http://www.php.net/manual/en/language.operators.bitwise.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With