troubleshooting Question

Sort List of Variables by Numerical Value of the Variables, and Return Sorted (String) List of the Variables

Avatar of FrankTech
FrankTech asked on
5 Comments2 Solutions250 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros