Adding values in an array [duplicate]
Possible Duplicate:
How can i add all of my array values together in PHP?
I would like to add the numbers up in the array $m[2] for a total number of players online.
Whats the simplest way to do that, so I 开发者_运维技巧have the variable $total?
$c = curl_init();
curl_setopt_array($c, array(
CURLOPT_URL => 'http://www.bungie.net/stats/reach/online.aspx',
CURLOPT_RETURNTRANSFER => true,
));
$r = curl_exec($c);
curl_close($c);
preg_match_all('|([\w\s]+)</a> </h4>\s*([0-9,]+) Players|s', $r, $m);
$teams = array_combine($m[1], $m[2]);
foreach ($m[2] as &$v) $v = str_replace(',','',$v);
echo '<pre>'.print_r($m[2],1).'</pre>';
array_sum() ?
精彩评论