开发者

Adding values in an array [duplicate]

This question already has answers here: Closed 11 years ago.

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() ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜