Question: 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) { return !empty($a);}
$arr = array("abc",'','ghi');
$res = array_filter($arr, "callback");

```

it works as expected.

But if i use array\_filter like that :

```
$arr = array("abc",'','ghi');
$res = array_filter($arr, function($a) { return !empty($a);});

```

It fails with the error :

```
PHP Parse error:  syntax error, unexpected T_FUNCTION in test.php on line 2

```

What am i doing wrong ?

Answer: 
It seems that you’re using a PHP version that does not support [anonymous functions](http://php.net/functions.anonymous) (available since PHP 5.3.0).

But [`array_filter`](http://php.net/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](http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting)) will be removed.
> 
> 
>
It works well with PHP5. Check your PHP version, and upgrade if necessary.