Saturday, 15 March 2014

php - what does array_filter with no callback do? -



php - what does array_filter with no callback do? -

i came across code:

array_filter( array_map('intval', $array) );

it seems homecoming entries of $array converted int number > 0

however can't see on manual page defined. supposed homecoming array value if callback function evaluates true. there no callback function defined here.

confusing callback function optional on manual page: http://php.net/manual/en/function.array-filter.php

removes empty or equivalent empty:

example #2 array_filter() without callback

$entry = array( 0 => 'foo', 1 => false, 2 => -1, 3 => null, 4 => '' ); print_r(array_filter($entry));

result

array ( [0] => foo [2] => -1 )

php arrays

No comments:

Post a Comment