troubleshooting Question

Sort a multid array

Avatar of is_numeric
is_numeric asked on
PHP
6 Comments2 Solutions435 ViewsLast Modified:
Hi

What is the best way to sort a multi-d array ....

Would like to sort the 1st dimension based on  2nd dimension  price3 key value.

Sorted ascending (lowest value first.)

So in my example key [0] would swap with key [1]

[options] => Array
                (
                    [0] => Array
                        (
                            [0] => 519
                            [product_price_id] => 519
                            [1] => 4042
                            [product_id] => 4042
                            [2] => 160
                            [width] => 160
                            [3] => 230
                            [length] => 230
                            [4] => 0
                            [size_id] => 0
                            [5] => 570.00
                            [price1] => 570.00
                            [6] => Was
                            [price1_type] => Was
                            [7] => 285.00
                            [price2] => 285.00
                            [8] => Sale
                            [price2_type] => Sale
                            [9] => 213.75
                            [price3] => 213.75
                            [10] => Now
                            [price3_type] => Now
                            [11] => 
                            [size] => 
                        )

                    [1] => Array
                        (
                            [0] => 518
                            [product_price_id] => 518
                            [1] => 4042
                            [product_id] => 4042
                            [2] => 120
                            [width] => 120
                            [3] => 180
                            [length] => 180
                            [4] => 0
                            [size_id] => 0
                            [5] => 336.00
                            [price1] => 336.00
                            [6] => Was
                            [price1_type] => Was
                            [7] => 168.00
                            [price2] => 168.00
                            [8] => Sale
                            [price2_type] => Sale
                            [9] => 126.00
                            [price3] => 126.00
                            [10] => Now
                            [price3_type] => Now
                            [11] => 
                            [size] => 
                        )

                )
ASKER CERTIFIED SOLUTION
Pyromanci

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers 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 2 Answers 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