Callback function in array_filter

fuggii

New Member
I'm trying to delete empty elements in an array with the function array_filter.When i use an external callback like this :\[code\]function callback($a) { return !empty($a);}$arr = array("abc",'','ghi');$res = array_filter($arr, "callback");\[/code\]it works as expected.But if i use array_filter like that :\[code\]$arr = array("abc",'','ghi');$res = array_filter($arr, function($a) { return !empty($a);});\[/code\]It fails with the error :\[code\]PHP Parse error: syntax error, unexpected T_FUNCTION in test.php on line 2\[/code\]What am i doing wrong ?
 
Back
Top