$r, 'blue' => $b, 'white' => $w, 'violet' => 0 ); makeViolet($balls); echo $balls['violet']; function makeViolet(&$balls): void{ $violets = ($balls['red'] + $balls['blue'] + $balls['white']) / 2; $balls['violet'] = floor($violets); }