thinkphp如何使用foreach遍历数组并添加属性(下标)
使用下面代码即可
foreach ($list as &$value){ $from_time=Db::table('txsh_group_chat')->where(['user_id'=>$user_id,'group_id'=>$value['group_id']])->field('latest_time')->find(); if($from_time['latest_time']==null){ $from_time['latest_time']==null; } $value['count']=$text->get_group_count($value['group_id'],$from_time['latest_time'],$value['latest_time']); }