-2

Following is my array

Array
(
    [0] => Array
        (
            [1] => Beanie
        )

    [1] => Array
        (
            [2] => Cap
        )

    [2] => Array
        (
            [1] => Beanie with Logo
        )

)

I want this into a single array like set key and value of array.

array(
    [1]=>Beanie,
    [2]=>Cap,
    [1]=>Beanie with Logo,
)
Samir Sheikh
  • 2,283
  • 2
  • 19
  • 37

1 Answers1

1

Demo Link.

You can do,

array_merge(...$arr);

Splat operator will expose to all the values of array internally, to flatten array.

Your expected output is not possible in any coding language with arrays.

Note: Indexes are mean to be unique, don't issue over its uniqueness :)

Rahul
  • 18,271
  • 7
  • 41
  • 60