function all_building_cumulate ($user_building) { $total = 0; while($data = current($user_building)) { $bats = array_keys($data); $tot = 0; foreach($bats as $key) { $Ti = 0; $Ca = 0; $Tr = 0; $level = $data[$key]; if($level=="") $level = 0; echo $key." : ".$level."
"; if($key == "Ti" || $key == "Ca" || $key == "Tr" || $key == "CG" || $key == "CaT" || $key == "UdD" || $key == "UdA" || $key == "UA" || $key == "STi" || $key == "SCa" || $key == "STr" || $key == "CT" || $key == "Ter" || $key == "HM" || $key == "CM" || $key == "Sat") { if($level > 0) list($Ti, $Ca, $Tr) = array_values(building_cumulate($key, $level)); $tot += $Ti + $Ca + $Tr; $total += $Ti + $Ca + $Tr; echo number_format($Ti+$Ca+$Tr,2,","," ")."
"; } } echo number_format($tot,2,","," "); echo "

"; next($user_building); } return $total; }