Scummy12 Posted December 21, 2010 Share Posted December 21, 2010 This is my current script <?php $iFile = "accounts.txt"; //Put your list lagger's info in this txt file in the same directory as this script. Format is UserID(space)AuthKey $login = file($iFile, FILE_SKIP_EMPTY_LINES); if(!is_file($iFile)) echo "The logins file couldn't be found...".sleep(999999); foreach($login as $line_num => $line) { $login = explode(" ", htmlspecialchars(str_replace(" "," ",$line))); //////////////// ////////////// /////////// ///////// if(stristr($login[1], "\n")) $login[1] = substr($login[1], 0, strlen($login[1])-2); $MobLink = "http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/"; $RefreshStat = file_get_contents($MobLink."refresh_stat?user_id=".$login[1]."&auth_key=".$login[0]); $Mob_Name = explode("<mob_name>", $RefreshStat); $Mob_Name = explode("<", $Mob_Name[1]); $Name = $Mob_Name[0]; $Cash = explode("<cash>", $RefreshStat); $Cash = explode("<", $Cash[1]); $CurrentCash = $Cash[0]; echo $Name."-$".number_format($CurrentCash)." - ".$login[1]."\n"; } sleep(99999); ?> The Script runs through for 100 different accounts, is it possible to add all the Cash values that get echo'd? Link to comment https://forums.phpfreaks.com/topic/222264-adding-numbers/ Share on other sites More sharing options...
QuickOldCar Posted December 21, 2010 Share Posted December 21, 2010 For something simple as adding all the values of an array. <?php $cash_array = array(234,34,876,21,21,324); foreach ($cash_array as $cash) { $total_cash = array_sum($cash_array); } echo "Total cash = ".$total_cash."<br>"; ?> I suppose if need to show the process can make $cash into a new array as $cash[] and in a loop do a $cash + $cash, is just like doing regular math. I believe $CurrentCash is already the array. $cash[] Link to comment https://forums.phpfreaks.com/topic/222264-adding-numbers/#findComment-1149741 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.