我已经花了几个小时来解决这个问题,但没有任何可用的结果。也许有人可以帮我解决这个问题,我想在一个类中使用它,所以我想构建一个方法,将数组作为输入,将重建数组作为输出
我有这个数组:
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
)
)
这个数组应该被转换成这个:
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:示例的值也是数组,我想处理一些操作。例如 0-9 是一个动作并停止,但 0-10 有孩子。如果 0-10 完成并返回 true 或 false,则下一个孩子被解雇。如果为真 10-11 否则为 10-12。这是我第一次上这个论坛,很抱歉给您带来不便
EDIT2:也许这个例子有帮助,这是 JSON 中发布的字符串。我在数据库中有几条规则,这将有助于为工作挑选合适的文章。
$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"
)
)
)
)