0

In php ,I have a array like this:

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

And now I want array like that:

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

any good ideas? in php language!

10
  • How would you plan to address items in such an array? Commented Jan 17, 2018 at 5:28
  • do you want to make an array of arrays a single array ? Commented Jan 17, 2018 at 5:31
  • 6
    What is the difference between 2 arrays? Commented Jan 17, 2018 at 5:31
  • so you want to split first array to two seperate array? because if you want expected outcome as a single array, then both input and expected outcome is identical(no difference) Commented Jan 17, 2018 at 5:31
  • Your both arrays are same.. Difference is just you entered manually.. Coding point of view both arrays are same. Commented Jan 17, 2018 at 5:33

1 Answer 1

1

Check this,

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

echo json_encode($arr);

Output

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

Here is working demo,

json_encode — Returns the JSON representation of a value

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.