Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. <?php
  2. $people = [
  3.     ['name'=> 'Silvia' , 'height'=> 1.69],
  4.     ['name'=> 'Martin' , 'height'=> 1.82],
  5.     ['name'=> 'Pesho' , 'height'=> 1.55],
  6.     ['name'=> 'Linda' , 'height'=> 1.88],
  7. ];
  8. $averageHeight = array_reduce ($people, function ($carry, $item) {
  9.         return $carry + $item['height'];});
  10.  
  11. echo $averageHeight / count($people);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement