R
R
Romi2021-10-22 21:12:15
Laravel
Romi, 2021-10-22 21:12:15

Is there something in Laravel to select members of a certain type from an array or collection, eg. string or int?

subject :)

It's easy for me to write) but suddenly there is already something native?

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-10-23
@romicohen

collect($items)->filter(function($item) {
    return is_int($item);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question