有一个二维数组,我想取出其中一个key的集合,并计算总和 二维数组取某个键值集合 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $ar = array ( 0 => array ( 'id' => '5', 'title' => '相宜本草八倍凝水霜50g 保湿补水滋润美白面霜乳液男女正品护肤品', 'images' => 'uploadfile/goods/2015-01/1420774763.jpg', 'price' => '39.0', 'num' => '1', 'total' => '39', 'wlmoney' => '0', 'url' => 'http://localhost/dkyq/goods.php?id=12', ), 1 => array ( 'id' => '4', 'title' => '美肤宝正品 水份源洁面膏洁面乳75ml 洗面奶清洁爽肤 补水保湿', 'images' => 'uploadfile/goods/2015-01/1420773795.jpg', 'price' => '12.0', 'num' => '1', 'total' => '12', 'wlmoney' => '0', 'url' => 'http://localhost/dkyq/goods.php?id=11', ),);$total = 0;foreach($ar as $r) $total += $r['total'];echo $total; //51 $arr = array( array( 'id' => '5', 'title' => '相宜本草八倍凝水霜50g 保湿补水滋润美白面霜乳液男女正品护肤品', 'images' => 'uploadfile/goods/2015-01/1420774763.jpg', 'price' => '39.0', 'num' => '1', 'total' => '39', 'wlmoney' => '0', 'url' => 'http://localhost/dkyq/goods.php?id=12', ), array( 'id' => '4', 'title' => '美肤宝正品 水份源洁面膏洁面乳75ml 洗面奶清洁爽肤 补水保湿', 'images' => 'uploadfile/goods/2015-01/1420773795.jpg', 'price' => '12.0', 'num' => '1', 'total' => '12', 'wlmoney' => '0', 'url' => 'http://localhost/dkyq/goods.php?id=11', ));$total = 0;foreach($arr as $v){ $total += $v['total'];}echo $total;total = 51 如何将个位十位百位...分开显示? PHP 将二维数组转成一维数组 键名保持不变 并且去掉空元素 .htaccess转换httpd格式 急求高手帮助!!! smarty中第二次循环不显示? 有关imagecreatefromgif()的问题 请问大哥.VhostQouta是什么东东啊 不希望url上出现php?field=11之类的,有办法没? 请高手帮忙,我想你们也碰到过 字符串就是数组吗 php的floor函数问题 iframe里面是其他网站,怎么提取或者控制里面的内容?
0 => array (
'id' => '5',
'title' => '相宜本草八倍凝水霜50g 保湿补水滋润美白面霜乳液男女正品护肤品',
'images' => 'uploadfile/goods/2015-01/1420774763.jpg',
'price' => '39.0',
'num' => '1',
'total' => '39',
'wlmoney' => '0',
'url' => 'http://localhost/dkyq/goods.php?id=12',
),
1 => array (
'id' => '4',
'title' => '美肤宝正品 水份源洁面膏洁面乳75ml 洗面奶清洁爽肤 补水保湿',
'images' => 'uploadfile/goods/2015-01/1420773795.jpg',
'price' => '12.0',
'num' => '1',
'total' => '12',
'wlmoney' => '0',
'url' => 'http://localhost/dkyq/goods.php?id=11',
),
);$total = 0;
foreach($ar as $r) $total += $r['total'];
echo $total; //51
$arr = array(
array(
'id' => '5',
'title' => '相宜本草八倍凝水霜50g 保湿补水滋润美白面霜乳液男女正品护肤品',
'images' => 'uploadfile/goods/2015-01/1420774763.jpg',
'price' => '39.0',
'num' => '1',
'total' => '39',
'wlmoney' => '0',
'url' => 'http://localhost/dkyq/goods.php?id=12',
),
array(
'id' => '4',
'title' => '美肤宝正品 水份源洁面膏洁面乳75ml 洗面奶清洁爽肤 补水保湿',
'images' => 'uploadfile/goods/2015-01/1420773795.jpg',
'price' => '12.0',
'num' => '1',
'total' => '12',
'wlmoney' => '0',
'url' => 'http://localhost/dkyq/goods.php?id=11',
)
);
$total = 0;
foreach($arr as $v){
$total += $v['total'];
}
echo $total;
total = 51