Remove empty array elements with array_filter with a callback function

后端 未结 2 1479
我在风中等你
我在风中等你 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.

    0 讨论(0)
  • 2021-01-17 18:37

    It works well with PHP5. Check your PHP version, and upgrade if necessary.

    0 讨论(0)
提交回复
热议问题