Hi everyone,
I'm trying to make a custom sort function to sort an array with string keys and integer values, with some of the values repeated. I need it to maintain key/value associations, but sort it in reverse value order.
I've tried all the built-in PHP sort functions, and all of them eliminate the repeated values, so this doesn't work. I tried to write a custom function SortThis() and PHP keeps showing a parse error in the line containing the function declaration (the first line shown here).
function SortThis($myArray) {
$newArray=array():
$firstCount=max($myArray);
for($currCount=$firstCount; $currCount > 0; --$currCount) {
foreach($myArray as $key => $value) {
if ($value==$currCount) {
$tempArray=array($key => $value);
$newArray=array_merge($newArray, $tempArray);
}
}
}
return $newArray;
}
Any suggestions? Thanks in advance for your help.