I already spent some hours figuring this one out but without any usable result. Maybe someone could help me out with this one, i want to use it inside a class so I want to build a method with as input the array and as output the rebuild array
I have this array:
Array
(
[0] => Array
(
[5] => 0-5
[8] => 0-8
[9] => 0-9
[10] => 0-10
)
[10] => Array
(
[11] => 10-11
[12] => 10-12
)
[11] => Array
(
[13] => 11-13
)
[12] => Array
(
[14] => 12-14
)
)
And this array should be transformed to this one:
Array
(
[0] => 0-5
[1] => 0-8
[2] => 0-9
[3] => Array
(
[0] => 0-10
[1] => Array
(
[0] => 10-11
[1] => Array
(
[0] => 11-13
)
[2] => 10-12
[3] => Array
(
[0] => 12-14
)
)
)
)
EDIT1: The values of the examples are also arrays en with this I want to process some actions. For example 0-9 is one action and stops but 0-10 has children. If 0-10 is finished and return true or false the next child is fired. If true 10-11 else 10-12. It is my first time on this forum sorry for any inconvenience
EDIT2: Maybe this example helps, this is the posted string in JSON. I have a couple of rules in the database wich will help to pick the right article for the job.
$postdata = '{"next":false,
"data":{"name":"patrick",
"etc":"etc",
"MotionDetection":"yes",
"nameOfTheRoom": ["Room1","Room2","Room3"],
"havePets":"yes"}';
Array
(
[0] => 0-5
[1] => 0-8
[2] => 0-9
[3] => Array
(
[0] => "yes" // MotionDetection
[1] => Array
(
[0] => "yes" // Have Pets
[1] => Array
(
[0] => "CountRecords" // Count nameOfTheRoom
[1] => "insertArticle A"
)
[2] => "No" // Have Pets
[3] => Array
(
[0] => "CountRecords" // Count nameOfTheRoom
[1] => "insertArticle B"
)
)
)
)