1

Hello everyone i get some problem when try learn php with laravel, there is the problem ...

i have an array structure like this :

array:3 [▼
  0 => 16
  1 => 19
  2 => 15
]

how can u change the array structure to look like this :

array:3 [▼
  0 => array:1 [▼
    0 => 16
  ]
  1 => array:1 [▼
    0 => 19
  ]
  2 => array:1 [▼
    0 => 15
  ]
]

im newb ,can somebody help me, im using laravel 5.8 ,very grateful if someone helps. sorry for my broken english.

1

1 Answer 1

1

i found it !

use array_chunck()

$convert = array_chunk($data, 1);

dd($convert);

output:

array:3 [▼
  0 => array:1 [▼
    0 => 16
  ]
  1 => array:1 [▼
    0 => 19
  ]
  2 => array:1 [▼
    0 => 15
  ]
]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.