I have an array consisting of 4 fields.
$retval[] = array(
"name" => "$dir$entry/",
"type" => filetype("$dir$entry"),
"size" => 0,
"lastmod" => filemtime("$dir$entry")
);
I want to sort this array depending on a variable, which contains either 1 of the 4 field (eg: type, name etc)
$sortBy = $_GET['sortBy'];
This function should use the $sortBy variable:
function compare_field($a, $b){
return strnatcmp($a["'.$sortBy.'"], $b["'.$sortBy.'"])
}
And is called like this:
usort($retval, "compare_field");
But the construction doesn't work ..
Hope someone can point me in the right direction, being the obvious newby I am.