Jump to content

foreach loop help


victorianrider

Recommended Posts

Hey guys, need help on some addition.

 



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);
  $account_data[$line_num] = array($login[0], $login[1]);
$UserID = $login[0];
$AuthKey = $login[1];
$MobLink = "http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/";
$RefreshStat = file_get_contents($MobLink."refresh_stat_manual?user_id=".$UserID."&auth_key=".$AuthKey);
$Cash = explode ("<cash>", $RefreshStat);
$Cash = explode ("<", $Cash[1]);
$Cash = $Cash[0];
$CashForEcho = "$".number_format($Cash[0]);
echo $CashForEcho."<br/>";
echo "<br/><br/>";
}


 

The variable $Cash will be dynamic for each user I put in the $login_file, and I need to add all of those values up. So say I put in 3 users within the $login_file, and the $Cash for user 1 was $3,000, the $cash for user 2 was $6,000 and the $cash for user 3 was $1,000, I want to be able to automatically add them all up, so it would echo '$10,000' at the end. Hope I've explained it for you guys to understand easily enough, if not let me know.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/221012-foreach-loop-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.