troubleshooting Question

Sort part of an array by value of specific key

Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland asked on
PHP
6 Comments1 Solution66 ViewsLast Modified:
Hi

I'm unsure how to sort by one of the key values in this array (it's part of a bigger one) but I want to loop through ERates->In and display "RateBreak" and "Rate" BUT sort by "Hours"

I'll obviously then do the same for ERates->Out

Thanks

  "ERates": {
    "In": [
      {
        "RateBreak": "½ Hour",
        "Rate": 100,
        "Hours": 0.5,
        
      },
      {
        "RateBreak": "1 Hour",
        "Rate": 200,
        "Hours": 1,
        
      },
      {
        "RateBreak": "Overnight",
        "Rate": 1000,
        "Hours": 10
      },
      {
        "RateBreak": "15 mins",
        "Rate": 70,
        "Hours": 0.25
        
      }
    ],
    "Out": [
      {
        "RateBreak": "½ Hour",
        "Rate": 150,
        "Hours": 0.5
        
      },
      {
        "RateBreak": "1 Hour",
        "Rate": 250,
        "Hours": 1
        
      },
      {
        "RateBreak": "Overnight",
        "Rate": 1200,
        "Hours": 10
      },
      {
        "RateBreak": "15 mins",
        "Rate": 100,
        "Hours": 0.25
        
      }
    ]
  }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
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 1 Answer and 6 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