Jump to content

Combining then sorting to associative arrays


c_shelswell

Recommended Posts

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!

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..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.