算法积累之拼接字符串

$aTrainMem = $this->dao_rtraining->getTraAndMem($where,'training_level asc',false,false,false,'training_level',false);
            foreach ($aTrainMem as $k => $v) {
                isset($outData[$v['training_level']])? $outData[$v['training_level']]++ : $outData[$v['training_level']] = 1 ;
            }
            //Array ( [1] => 2 [2] => 2 [3] => 1 [4] => 2 )
            //Array ( [3] => 1 )
            $outstr = '';
            for ($i = 1;$i<=4;$i++) {
                if(!isset($outData[$i])){
                    if($i == 1){
                        $outstr .= "0"; 
                    }else{
                        $outstr .= ",0"; 
                    }
                }else{
                    if($i == 1){
                        $outstr .= $outData[$i]; 
                    }else{
                        $outstr .= ",".$outData[$i]; 
                    }
                }
            }
            $this->view_->assign('outData',$outstr);

获取数据之后,要进行一些处理。

posted @ 2014-06-18 15:08  TBHacker  阅读(377)  评论(0编辑  收藏  举报