PHP中給數組中追加元素

在寫接口的時候,有的參數需要合併成一個數組

如上,需要把選中的合併到上邊的數組裏邊去

達到如上效果

實現代碼如下

public function doPagecourseInfo()
    {
        global $_W, $_GPC;
        $uniacid = $_W['uniacid'];
        $id = $_GPC['id'];
        $course = pdo_fetch("select * from ".tablename('yzpx_sun_course')." where `uniacid`='$uniacid' and id='$id'");
        // $common=pdo_getall('yzpx_sun_news', array('uniacid' => $_W['uniacid'],'id'=>$id));
        $course['createtime'] = date('y-m-d', $course['createtime']);
        $lesson = pdo_fetchcolumn("select count(*) from " . tablename("yzpx_sun_lesson")  ."where couid =".$id);
        //將lesson追加給數組course
        $course['lesson']=$lesson;
        return $this->result(0, 'success', $course);
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章