kornmonkie Posted February 6, 2010 Share Posted February 6, 2010 Hey, I have 3 arrays of info that have been pulled from a database. Here are the names of the arrays. $idcheck[$k] $titlecheck[$k] $raritycheck[$k] Each array is related, so $idcheck[1], $titlecheck[1] and $raritycheck[1] all have info related to each other. Displaying $idcheck[1], $titlecheck[1] and $raritycheck[0] for example, would mismatch the info. What I'm looking to do is setup a way to sort one array, and have the others follow suit. If $idcheck[1] is sorted alphabeticly, $titlecheck[1] and $raritycheck[1] will still be associated with $titlecheck[1] and be sorted as well. I'm looking to display the info from all three. I was thinking of using array_multisort, but I am confused by the php site's description of the function. I hope this makes sense. Let me know if I am being unclear. Cheers. Link to comment https://forums.phpfreaks.com/topic/191119-sorting-multiple-arrays/ Share on other sites More sharing options...
trq Posted February 6, 2010 Share Posted February 6, 2010 If these arrays are meant to be related they really shouldn't be in separate arrays in the first place. That is the problem. Fix that, and you'll be able to sort them much more easily. Link to comment https://forums.phpfreaks.com/topic/191119-sorting-multiple-arrays/#findComment-1007756 Share on other sites More sharing options...
kornmonkie Posted February 6, 2010 Author Share Posted February 6, 2010 I pretty much figured it out. array_multisort($idcheck, $titlecheck, $raritycheck); Link to comment https://forums.phpfreaks.com/topic/191119-sorting-multiple-arrays/#findComment-1007802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.