Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $magassagok = array(
- 'ferfiak' => array(1, 2, 100, 150, 200),
- 'nok' => array(3, 4, 5, 6, 10)
- );
- function atlagmagassag($data)
- {
- $atlagok = array();
- $osztoszam = 0;
- $temp = 0;
- foreach ($data as $nem => $magassag)
- {
- $osztoszam = count($magassag);
- $temp = 0;
- foreach($magassag as $index => $value)
- {
- if ($index < $osztoszam )
- {
- $temp += $value;
- }
- if ($index == ($osztoszam-1) )
- {
- $atlagok[$nem] = ($temp/$osztoszam);
- }
- }
- }
- return $atlagok;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement