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

问题描述 投票:-4回答:1

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

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

            )



    )

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

有什么建议吗?

php arrays
1个回答
3
投票

你可以用以下方式做:

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

推荐问答