Filtering Arrays Using array_filter() in PHP


Filter elements of an array using a callback function.

Source Code

function odd($var) {
    return($var & 1);
}
$input = array(1, 2, 3, 4, 5, 6);
$output = array_filter($input, "odd");
print_r($output);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments