<?php
function test_odd($var)
{
return($var & 1);//位(bitwise)運算
}php
$a1=array("a","b",2,3,4);
print_r(array_filter($a1,"test_odd"));//Array ( [3] => 3 )
?>it
補充1:io
<?php
$r1 = (0 & 0);//0
$r2 = (1 & 0);//0
$r3 = (1 & 1);//1
$r4 = (0 & 1);//0
$str = 'abc';
$r6 = ($str & 1);//0
$r7 = (123 & 1);//1
?>function
補充2:test
<?php
$array = array(filter
0 => '霜天部落',co
1 => false,return
2 => 1,ab
3 => null,
4 => '',
5 => 'http://www.xxx.com',
6 => '0'
);
print_r(array_filter($array));//Array ( [0] => 霜天部落 [2] => 1 [5] => http://www.xxx.com )
?>