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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.