Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel collection average

$average = collect([['foo' => 10], ['foo' => 10], ['foo' => 20], ['foo' => 40]])->avg('foo');

// 20

$average = collect([1, 1, 2, 4])->avg();

// 2
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #laravel #collection #average
ADD COMMENT
Topic
Name
9+7 =