Answer the question
In order to leave comments, you need to log in
How to remove an item from a laravel collection?
There is a selection from the table
Collection {#561 ▼
#items: array:3 [▼
0 => Test {#562 ▶}
1 => Test {#563 ▶}
2 => Test {#564 ▶}
]
}
Collection {#561 ▼
#items: array:3 [▼
0 => Test {#562 ▶}
2 => Test {#564 ▶}
]
}
Answer the question
In order to leave comments, you need to log in
We read the documentation , there are a lot of interesting things.
$collection = collect(['Я', 'не', 'читаю', 'документацию']);
$collection->forget(1);
$collection->dump(); // ['Я', 'читаю', 'документацию']
unset
it will also work:
And even this is not all, in general, as I already said: read the documentation. unset($collection[1]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question