php关于数组到数组

时间:2018-01-17 05:27:06

标签: php arrays multidimensional-array

在php中,我有一个这样的数组:

[
    [0] =>
        [
            [0] => 255
            [1] => 216
            [2] => 255
        ]
    [1] =>
        [
            [0] => 25
            [1] => 54
            [2] => 25455
        ]
]

现在我想要这样的数组:

[
    [0] => 255
    [1] => 216
    [2] => 255
]
[
    [0] => 25
    [1] => 54
    [2] => 25455
]

有什么好主意吗?用PHP语言!

1 个答案:

答案 0 :(得分:1)

检查一下,

<?php
        $arr = [
    0 =>
        [
            0 => 255,
            1 => 216,
            2 => 255,
        ],
    1 =>
        [
            0 => 25,
            1 => 54,
            2 => 25455,
        ]
];

echo json_encode($arr);

<强>输出

[[255,216,255],[25,54,25455]]

这是工作demo

json_encode - 返回值

的JSON表示