I have found a multi-dimensional array that holds an array of several session IDs and field data and looks like this: P>
As you can see, the first 2 field array records have the same data. So far I've written the following part of the PHP code to make it unique and sorting the date. ($ I = 0; $ i & lt; counts ($ canceled output); $ i ++) {usort ($ unsortedoutput [$ i] ['fields'], 'sort function')
$ unique [] = array_map ('unserialize', array_unique (array_map ('serialize', $ unassigned output [$ i] ['field']))); }
This works, but when I print the $ unique
array, then it (as expected) [session_id]
and [field]
key:
array ([102] = & gt; array ([0] = & gt; ([Date_time] => 2013-03-25 16:28: 56 [ip_address] => 94.229.1.233 [user_name] = & gt; public.static [session_type] = & gt; start)
My question is:
I used to multiply my multi-dimensional array while maintaining the entire structure. I think I am close, but I can not understand the rest.
= Post- As an alternative, you can call
You can use each copy to change the and
context with foreach
: foreach ($ unsortedOutput as & amp; $ O) {usort ($ o ['fields'], 'sortfunction'); $ o ['fields'] = array_map ('unserialize', AR Ray_unique (array_map ('serialize', $ o ['fields']) )); }
No comments:
Post a Comment