Support the ongoing development of Laravel.io →
Eloquent

Illuminate\Support\Collection avg() and average() function gives unexpected result on collection class in laravel 5.4 version for example : $collection = collect([['c'=>1], ['b'=>2], ['c'=>3]])->avg('c'); return $collection; result : 1.3333333333333

Last updated 3 years ago.
0

this is too ---->$collection = collect([1, 2, 3, 4, 5, 6, 7]);

$chunks = $collection->chunk(4);

$chunks->toArray(); result : [[1,2,3,4],{"4":5,"5":6,"6":7}]

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.