Home > database >  How can I select an item from an array?
How can I select an item from an array?

Time:09-26

in this screenshot i have 2 array items enter image description here i want select each 'count' item !!considering that the number of arrays can be infinite. I want to select 'count' each array.

CodePudding user response:

If you are using laravel then laravel has collections to manage these types of complicated scenarios, simply change the array to collection and pluck the count from the collection.

$collect = collect($yourArrayName);
$plucked = $collect->pluck('count');
dd($plucked->all());

https://laravel.com/docs/9.x/collections#method-pluck

CodePudding user response:

when i use collections for one items this evrey thing is ok , but adding another items to pluck just output this : code

output

one items pluck

  • Related