it gave me the following error:
Parse error: syntax error, unexpected T_FUNCTION in /home/content/80/9944080/html/modules/CGExtensions/lib/class.cge_array.php on line 171
This is the code that i extracted from the file above
and the problem according to the parse error is in the line:
$func = function($a,$b) use ($key,$is_string,$casecompare)
I can't seem to figure what's wrong
Code: Select all
/**
* Sort array of hashes by key
**/
static public function hashsort(&$input,$key,$is_string = false,$casecompare = false)
{
$func = function($a,$b) use ($key,$is_string,$casecompare) {
if( $is_string ) {
if( $casecompare ) {
return strcasecmp($a[$key],$b[$key]);
}
else {
return strcmp($a[$key],$b[$key]);
}
}
if( $a[$key] == $b[$key] ) return 0;
if( $a[$key] < $b[$key] ) return -1;
return 1;
};