Answer the question
In order to leave comments, you need to log in
How to parse arrays according to the principle of who is the last one and slippers?
Greetings!
I probably already got everyone with these arrays.
The bottom line is that there are arrays of dates with values (values \u200b\u200bcan be anything, for example, the alphabet)
It is necessary to parse them somehow, provided that the next array is always true and replaces / divides the previous one.
I will show clearly.
Initial data example
array:3 [
0 => array:6 [
"2018-03-05" => "a"
"2018-03-06" => "b"
"2018-03-07" => "c"
"2018-03-08" => "d"
"2018-03-09" => "e"
"2018-03-10" => "f"
]
1 => array:4 [
"2018-03-07" => "g"
"2018-03-08" => "h"
"2018-03-09" => "i"
"2018-03-10" => "k"
]
2 => array:8 [
"2018-03-01" => "l"
"2018-03-02" => "m"
"2018-03-03" => "n"
"2018-03-04" => "o"
"2018-03-05" => "p"
"2018-03-06" => "q"
"2018-03-07" => "r"
"2018-03-08" => "s"
]
3 => array:3 [
"2018-03-04" => "t"
"2018-03-05" => "v"
]
]
array:3 [
0 => array:3 [
"2018-03-01" => "l"
"2018-03-02" => "m"
"2018-03-03" => "n"
]
1 => array:2 [
"2018-03-04" => "t"
"2018-03-05" => "v"
]
2 => array:3 [
"2018-03-06" => "q"
"2018-03-07" => "r"
"2018-03-08" => "s"
]
3 => array:2 [
"2018-03-09" => "i"
"2018-03-10" => "k"
]
]
Answer the question
In order to leave comments, you need to log in
Get the data structure "set".
Go through the external list in reverse order, for each element of the nested lists, check whether there is such an element in the set, if not, add it to the set and to the resulting list.
It is not clear on what basis you break the elements into lists.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question