1

我尝试对具有数值作为 key的递归数组进行放气。重复结构是带有键ANDORNOT的数组,以及带有数字作为键的数组内。我尝试递归地缩小键ANDORNOT内的数组

我有这个 :

$input=array(
    'Experiment.name' => (int) 0,
    ' AND ' => array(
        (int) 0 => array(
            'Experiment.note' => (int) 0
        ),
        (int) 1 => array(
            'Experiment.date' => (int) 0,
            ' AND ' => array(
                (int) 0 => array(
                    'Experiment.state' => (int) 0
                )
            )
        )
    )
)

并尝试获得:

$output=array(
    'Experiment.name' => (int) 0,
    ' AND ' => array(       
            'Experiment.note' => (int) 0
            'Experiment.date' => (int) 0,
            ' AND ' => array(
                    'Experiment.state' => (int) 0
            )
        )
    )
)

内数组可以有两个以上的数组,键可能不是 AND,可能是ANDOR AND NOT

4

1 回答 1

1

尝试:

$input[' AND '][0] = array_merge($input[' AND '][0], $input[' AND '][1]);
unset($input[' AND '][1]);
于 2013-10-24T18:46:16.743 回答