Answer the question
In order to leave comments, you need to log in
Laravel Collection change keys?
Good night guys there is an array
Array
(
[0] => Array
(
[name] => 412
)
[1] => Array
(
[name] => 3144
)
[2] => Array
(
[name] => 632
)
)
Answer the question
In order to leave comments, you need to log in
If we are talking about an array (the printout of which is given above, which is not a collection, despite the conditions of the problem), then:
$arr = ;
$new_arr = array_combine(range(1, count($arr)), array_values($arr));
var_dump($new_arr);
/*
array(3) {
[1]=>
array(1) {
["name"]=>
int(412)
}
[2]=>
array(1) {
["name"]=>
int(3144)
}
[3]=>
array(1) {
["name"]=>
int(632)
}
}
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question