The following function works in PHP > 5.3 but errors out in older versions. How can I modify this to make it 5.2 safe?
function _iniloader_get_dirs($dir) {
$dirs = array_filter(scandir($dir), function ($item) use ($dir) {
return (is_dir($dir.'/'.$item) && $item != "." && $item != "..");
});
// Use array_values to reset the array keys:
return array_values($dirs);
}
5.2 error:
Parse error: syntax error, unexpected T_FUNCTION ... on line 2
You can easily do it w/o the closure, but you will lose some elegance: