For a filemanagement, I use create_function
to sort folders(directories) first and then files. But it seems that create_function
is deprecated in php 7.2.
So how can I use the usort
below correctly?
$files = array_diff( scandir($dir), array(".", "..", "tmp") );
usort ($files, create_function ('$a,$b', '
return is_dir ($a)
? (is_dir ($b) ? strnatcasecmp ($a, $b) : -1)
: (is_dir ($b) ? 1 : (
strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION)) == 0
? strnatcasecmp ($a, $b)
: strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION))
))
;
'));