display nothing after sort array in php -
this question has answer here:
i want sort in ascending order field available_price in array, how can sort. following code
array ( [available_price] => 770 [category] => fashion design & theory [mrp] => 770 [source] => rediffbooks [title] => shoes [url] => http://books.rediff.com/book/five-point-someone/9781851775378 ) array ( [available_price] => 797 [mrp] => 938 [source] => uread-in [title] => shoes [url] => http://www.uread.com/search-books/9781851775378 )
... on...
you can use usort()
sort array based on available_price
:
$array = array( array( available_price => 770, category => "fashion design & theory", mrp => 770, source => "rediffbooks", title => "shoes", url => "http://books.rediff.com/book/five-point-someone/9781851775378" ), array( available_price => 797, mrp => 938, source => "uread-in", title => "shoes", url => "http://www.uread.com/search-books/9781851775378" ), ); // sort items in array in ascending order based on available_price usort($array, function($a, $b) { return $a['available_price'] > $b['available_price']; });
Comments
Post a Comment