CodeIgniter Forums
Merging data from 2 query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Merging data from 2 query (/thread-55897.html)



Merging data from 2 query - El Forum - 11-15-2012

[eluser]GabrieleMartino[/eluser]
Hello,

I have a table of contacts with user1_id and user2_id.
When I get back the contact list I don't know if the contact is in the left side or right.
I performed 2 query left and right.
I know I can merge the 2 query with array_merge.
Now I need to perform a sort on the column 'email'.
How can I do? I mean how can I make the sort($merged_query,'email')?

Thanks




Merging data from 2 query - El Forum - 11-16-2012

[eluser]GabrieleMartino[/eluser]
To have the job done is possible.

One need to set the format of the result of the queries in

Code:
arr1 =$query->result_array();

after it merge the 2 array

Code:
array_merge (arr1,arr2);

and at end sort with multisort function of php in which I remind a note to see how to order

array in a specific key order in php manual.