Started by Peter DanielsSep 25, 2021

Open
Laravel collection - finding the key of value matching a condition

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

Take the following example of array manipulation with the Illuminate\Support\Collection class provided by the Laravel Framework.

$value = $arr->firstWhere('age', '>', 18);
$key = $arr->search($value, true);

In this code example, php must traverse the array twice. How can I prevent this from happening?

0 Replies

You must be Logged in to reply
Techiio

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

facebooklinkdeintwitter

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Copyright techiio.com @2020 Kolkata, India
made with by Abhishek & Priyanka Jalan
Copyright techiio.com @2020
made with by Abhishek & Priyanka Jalan