A
A
Alexander Tishchenko2015-02-23 13:09:39
PHP
Alexander Tishchenko, 2015-02-23 13:09:39

how to change php array

Hello. Please help me change the array.
There is an array:

Array
(
    [0] => Array
        (
            [id] => 111
            [title] => title1
            [name] => picture
            [value] => img1.png
        )

    [1] => Array
        (
            [id] => 111
            [title] => title1
            [name] => width
            [value] => 600
        )

    [2] => Array
        (
            [id] => 111
            [title] => title1
            [name] => height
            [value] => 400
        )

    [3] => Array
        (
            [id] => 222
            [title] => title2
            [name] => picture
            [value] => img2.png
        )

    [4] => Array
        (
            [id] => 222
            [title] => title2
            [name] => width
            [value] => 800
        )

)

Should become like this:
Array
(
    [0] => Array
        (
            [id] => 111
            [title] => title1
            [nv] => Array
            (
            [0] => Array
                (
                    [name] => picture
                    [value] => img1.png
                )

            [1] => Array
                (
                    [name] => width
                    [value] => 600
                )

            [2] => Array
                (
                    [name] => height
                    [value] => 400
                )

            )
        )
    [1] => Array
        (
            [id] => 222
            [title] => title2
            [nv] => Array
            (
            [0] => Array
                (
                    [name] => picture
                    [value] => img2.png
                )

            [1] => Array
                (
                    [name] => width
                    [value] => 800
                )

           )
        )
)

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2015-02-23
@FanatPHP

In a cycle.
you go through the original array and form the desired one.
But you don't need it.

A
Anton, 2015-02-27
Semenov

to see it is accepted for work or some tests), otherwise I don’t see the point where such a strange array of results may be needed ... The fan is right

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question