FrankTech
asked on
Sort List of Variables by Numerical Value of the Variables, and Return Sorted (String) List of the Variables
I have 8 variables, e.g. $a, $b, $c, $d, $e, $f, $g, $h with various values (they change every time the PHP script runs). I need to put that list in descending order according to the numerical value of the variables -- but the final result needs to be a string listing the variables by name.
For example, if
$a = 2 $b = 9 $c = 4 $d = 0 $e = 3 $f = 8 $g = 7 $h = 1 then the resulting output should be a string like this: $string = "$b $f $g $c $e $a $h $d"
What is a good, efficient way to do that? I have a feeling it would involve putting the names and the values of the variables into a two-dimensional array, then sorting using array_multisort() . Would an expert like to show me how? Thanks.
For example, if
$a = 2 $b = 9 $c = 4 $d = 0 $e = 3 $f = 8 $g = 7 $h = 1 then the resulting output should be a string like this: $string = "$b $f $g $c $e $a $h $d"
What is a good, efficient way to do that? I have a feeling it would involve putting the names and the values of the variables into a two-dimensional array, then sorting using array_multisort() . Would an expert like to show me how? Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome :)
ASKER
TeRReF,
I have a follow-up question at http:Q_22773009.html if you would like to weigh in on it. Thanks.
I have a follow-up question at http:Q_22773009.html if you would like to weigh in on it. Thanks.
ASKER