Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

How to get one column from query Collection result as array?

I have an Illuminate\Support\Collection instance after getting the data.

The structure is an array:

#items => array: 400
    0 =>
        id: <some_id>
        email: <some_email>
    1 =>
        id: <some_id>
        email: <some_email>
    2 =>
        id: <some_id>
        email: <some_email>
    .. and more ..

How can I get for example all the emails as an array properly? I need the rest of the columns as well that's why I am not using pluck

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

Collection also has a pluck method:

$collection->pluck('email')
1 like

Please or to participate in this conversation.