c_shelswell Posted September 6, 2009 Share Posted September 6, 2009 Hi I've a bit of a puzzle that perhaps someone knows better than me if not i'll keep hunting. I basically have two arrays with different fields in them that I need to display in date order. I was thinking the best thing to do would be to combine them then sort them then to display do a foreach on them. Question is how do I select which field the arrays get sorted by? both have a date field but with different titles i.e. crt_insert_date & claim_insert_date can I select to sort by both? Any ideas would be really great - thanks! Link to comment https://forums.phpfreaks.com/topic/173345-combining-then-sorting-to-associative-arrays/ Share on other sites More sharing options...
RussellReal Posted September 6, 2009 Share Posted September 6, 2009 usort what that will do is pull up two results from the array at a time.. if you have a multi-dimensional array such as.. array ( [0] => array ( ['whatever'] => "lol" ['whatever'] => "lol" ['whatever'] => "lol" ) [1] => array ( ['whatever'] => "lol" ['whatever'] => "lol" ['whatever'] => "lol" ) ) it will pull up two elements from the arrays.. not the more inward arrays.. so inside of the callback function you will compare the fields inside of the arrays passed into the callback function against eachother and return -1 0 or 1 depending on whether to push back.. leave in place.. or send forward.. Link to comment https://forums.phpfreaks.com/topic/173345-combining-then-sorting-to-associative-arrays/#findComment-913766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.