function get_market_history_table(&$objAlliance) { $strMarketHistoryTable = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . "Market History" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<td>" . "Money" . "</td>" . "<td>" . "Food" . "</td>" . "<td>" . "Wood" . "</td>" . "<td>" . "Soldiers" . "</td>" . "</tr>"; $arrSum = array(MARKET_MONEY => 0, MARKET_FOOD => 0, MARKET_WOOD => 0, MARKET_SOLDIERS => 0); $objTmpUser = new clsUser(1); foreach ($objAlliance->get_userids() as $iUser) { $objTmpUser->set_userid($iUser); // This might speed it up a bit.. Reuse $arrTmpGoods = $objTmpUser->get_goods(); $arrTmpStats = $objTmpUser->get_stats(); $strMarketHistoryTable .= "<tr class=\"data\">" . "<th>" . stripslashes($arrTmpStats[TRIBE]) . "</th>" . "<td>" . number_format($arrTmpGoods[MARKET_MONEY]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_FOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_WOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_SOLDIERS]) . "</td>" . "</tr>"; // M: Add to total for each resource type foreach ($arrSum as $str => $i) { $arrSum[$str] += $arrTmpGoods[$str]; } } $arrAlli = $objAlliance->get_alliance_infos(); $strMarketHistoryTable .= "<tr class=\"data\">" . "<th class=bsup>" . "Unaccounted For:" . "</th>" . "<td class=bsup>" . number_format($arrAlli[MONEY] - $arrSum[MARKET_MONEY]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[FOOD] - $arrSum[MARKET_FOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[WOOD] - $arrSum[MARKET_WOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[SOLDIERS] - $arrSum[MARKET_SOLDIERS]) . "</td>" . "</tr>" . "</table>"; return $strMarketHistoryTable; }