I’m having the following array and I would like to order theme after the prices value. I have been checking in the php manual the array_multisort() function but it’s not really clear how could I achieve results.
my array looks
array=>(0=>array(id=>'1', name=>'example1', price='200'))
array=>(1=>array(id=>'2', name=>'example1', price='120'))
array=>(2=>array(id=>'3', name=>'example1', price='160'))
after the price value the order should be
array=>(1=>array(id=>'2', name=>'example1', price='120'))
array=>(2=>array(id=>'3', name=>'example1', price='160'))
array=>(0=>array(id=>'1', name=>'example1', price='200'))
Use usort():
MonkeyMonkeys’ alternative: