`How to rebuild an array?
A
A
Andrey Lepaskaln2020-05-04 15:45:26
PHP
Andrey Lepaskaln, 2020-05-04 15:45:26

How to rebuild an array?

Hello, I have such a situation, I get an array like this:
{ ["Name_Brand"]=> "Maxwill`s" ["Name"]=> "ShoriaSummer" }
{ ["Name_Brand"]=> "Maxwill` s" ["Name"]=> "Black"}
{ ["Name_Brand"]=> "Maxwill`s" ["Name"]=> "Altay"}
{ ["Name_Brand"]=> "Maxwill`s salt " ["Name"]=> "ShoriaSummer"}
{ ["Name_Brand"]=> "Maxwill`s salt" ["Name"]=> "Black"}
{ ["Name_Brand"]=> "Maxwill`s salt " ["Name"]=> "Altay"}
{ ["Name_Brand"]=> "Taboo" ["Name"]=> "Queen"}
{ ["Name_Brand"]=> "Taboo" ["Name"]=> "Origin"}
{ ["Name_Brand"]=> "Taboo" ["Name"]=> "Aida"}
{ [" Name_Brand"]=> "Taboo" ["Name"]=> "Eva"}

From this array in php, you need to make Name_Brand become like an id, for example like this:
{["Maxwill`s"] => {["Name"]=> "ShoriaSummer"},{["Name"]=> "Black"},{["Name"]=> "Altay"}}
{ ["Maxwill`s salt"] => {["Name"]=> "ShoriaSummer"},{["Name"]=> "Black"},{["Name"]=> "Altay"}}
{ ["Taboo"] => {["Name"]=> "Queen"},{["Name"]=> "Origin"},{["Name"]=> "Aida"},{["Name "]=> "Eva"}}

I apologize in advance for the unclear explanation of the assignment...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-05-04
@holoron

It is better to get it right away in the right form
https://phpdelusions.net/pdo/fetch_modes#FETCH_GROUP

T
ThunderCat, 2020-05-04
@ThunderCat

well, a loop, or array_map, whichever is more convenient...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question