phprookie72 Posted November 9, 2010 Share Posted November 9, 2010 I have an array as follow $data=array('team1'=>array('w'=>0,'l'=>1,'t'=>0,'pts'=>0', team2'=>array('w'=>1,'l'=>0,'t'=>0,'pts'=>3), 'team3'=>array('w'=>0,'l'=>0,'t'=>1,'pts'=>1) ) I would like to sort the data useing pts key in descending order, how would i go about doing that? thanks. Quote Link to comment Share on other sites More sharing options...
sasa Posted November 9, 2010 Share Posted November 9, 2010 <?php $data=array('team1'=>array('w'=>0,'l'=>1,'t'=>0,'pts'=>0), 'team2'=>array('w'=>1,'l'=>0,'t'=>0,'pts'=>3), 'team3'=>array('w'=>0,'l'=>0,'t'=>1,'pts'=>1) ); foreach ($data as $team => $value) $tmp[] = $value['pts']; array_multisort($data, SORT_DESC, SORT_NUMERIC, $tmp, SORT_DESC, SORT_NUMERIC); print_r($data); ?> Quote Link to comment Share on other sites More sharing options...
phprookie72 Posted November 9, 2010 Author Share Posted November 9, 2010 sweet thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.