Laravel Collection keys modification Laravel Collection keys modification laravel laravel

Laravel Collection keys modification


You can use Laravel Collection's values() method to make the the keys of a collection in a serialized order like this:

// Just for demonstration$collection = collect([    10 => ['fruit' => 'Apple', 'price' => 200],    11 => ['fruit' => 'Mango', 'price' => 500]]);$values = $collection->values();$values->all();/* Result would be:    [        0 => ['fruit' => 'Apple', 'price' => 200],        1 => ['fruit' => 'Mango', 'price' => 500],    ]*/