Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $people = [
- ['name'=> 'Silvia' , 'height'=> 1.69],
- ['name'=> 'Martin' , 'height'=> 1.82],
- ['name'=> 'Pesho' , 'height'=> 1.55],
- ['name'=> 'Linda' , 'height'=> 1.88],
- ];
- $averageHeight = array_reduce ($people, function ($carry, $item) {
- return $carry + $item['height'];});
- echo $averageHeight / count($people);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement