Remove empty array elements with array_filter with a callback function

后端 未结 2 1484
我在风中等你
我在风中等你 2021-01-17 18:05

I\'m trying to delete empty elements in an array with the function array_filter.

When i use an external callback like this :

function callback($a) {          


        
2条回答
  •  被撕碎了的回忆
    2021-01-17 18:24

    It seems that you’re using a PHP version that does not support anonymous functions (available since PHP 5.3.0).

    But array_filter does already filter empty values if you don’t specify a callback function:

    If no callback is supplied, all entries of input equal to FALSE (see converting to boolean) will be removed.

提交回复
热议问题