thinkphp中获取数组中的数组值

2017-8-26 06:10| 发布者: admin| 查看: 52| 评论: 0 |原作者: PT接口 |来自: PT接口

如,使用sql语句获取值:

$map=array();
$testtimes = date(‘Y-m-d 0:0:0’,strtotime(‘-7 day’));
$testtime = date(‘Y-m-d H:i:s’);//这是当前时间
$map[‘actionTime’] = array(‘between’,array(strtotime($testtimes),strtotime($testtime)));

$coinList = M(‘coin_log’)->where($map)->field(“actionTime,uid,sum(case when liqType in (‘2′,’3’) then coin else 0 end) as fanDianAmount,
0-sum(case when liqType in (‘101′,’102′,’103′,’7′) then coin else 0 end) as betAmount,
sum(case when liqType=6 then coin else 0 end) as zjAmount,
0-sum(case when liqType=107 then fcoin else 0 end) as cashAmount,
sum(case when liqType=1 then coin else 0 end) as rechargeAmount,
sum(case when liqType in (’50’,’51’,’52’,’53’) then coin else 0 end) as brokerageAmount”)->group(‘uid’)->select();
echo $coinList[0][‘rechargeAmount’];

执行以上语句后会显示以下数组内容:

array(1) {
  [0] => array(8) {
    ["actionTime"] => string(10) "1499875501"
    ["uid"] => string(3) "303"
    ["fanDianAmount"] => string(6) "0.0000"
    ["betAmount"] => string(7) "44.0000"
    ["zjAmount"] => string(6) "0.0000"
    ["cashAmount"] => string(8) "200.0000"
    ["rechargeAmount"] => string(9) "1000.0000"
    ["brokerageAmount"] => string(6) "0.0000"
  }
}

这样显示后,很多新手用户问,使用$coinlist['uid'] 这样来为什么显示不出来内容值,因为他这个是生成的二维数组,如果要取他后面的值,需在他前面设立编号!

$coinList[0]['uid']; 这样才可以全部显示出来!

<
返回顶部