如何在php中将二维数组制作成单个数组

时间:2017-12-23 10:46:54

标签: php arrays

我想将这个二维数组转换为单个数组, 我的数组结构如下所示。

Array
(
    [0] => Array
        (
            [0] => AccountTransaction Object
                (

                    [atrtid:AccountTransaction:private] => 1

                )

            [1] => AccountTransaction Object
                (

                    [atrtid:AccountTransaction:private] => 2

                )

        )

    [1] => Array
        (
            [0] => AccountTransaction Object
                (

                    [atrtid:AccountTransaction:private] => 1

                )

            [1] => AccountTransaction Object
                (

                    [atrtid:AccountTransaction:private] => 2

                )

        )

)

我希望它是

 Array
    (
        [0] => AccountTransaction Object
            (

                [atrtid:AccountTransaction:private] => 1

            )

        [1] => AccountTransaction Object
            (

                [atrtid:AccountTransaction:private] => 2

            )


        [2] => AccountTransaction Object
            (

                [atrtid:AccountTransaction:private] => 1

            )

        [3] => AccountTransaction Object
            (

                [atrtid:AccountTransaction:private] => 2

            )



    )

如何将其转换为以下格式。因此,所有内容都将在单个数组中而不是多维数组中。 有没有正确的方法呢?。对于我来说,进一步处理会更容易..

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

您可以采用以下方式:

$singleArray = call_user_func_array('array_merge', $twoDimensionalArray);