Link to home
Start Free TrialLog in
Avatar of FrankTech
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.
SOLUTION
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FrankTech
FrankTech

ASKER

Excellent. Thanks!
You're welcome :)
TeRReF,
    I have a follow-up question at http:Q_22773009.html  if you would like to weigh in on it. Thanks.