如何使用循环打印/回显result_array CodeIgniter(不是foreach)

时间:2019-06-11 02:48:56

标签: codeigniter for-loop

我使用const newDate = '2019-06-22' this.setState(({pressedDate}) => ({ pressedDate: { ...pressedDate, [newDate] : { dots: [vacation, massage, workout], selected: true } }, }))

返回函数
result_array()

但是,当我使用循环进行打印/回显时,这将返回空白/未打印

public function genJam($id_hari){
        $query  = $this->db->query("SELECT jam FROM mharijam WHERE hari=$id_hari ORDER BY jam");

        return $query->result_array();
    }

请帮助我,谢谢

1 个答案:

答案 0 :(得分:0)

您是否知道要一遍又一遍地调用该函数?

$result = $this->genJam(1);
$count = count($result);
if($count)
{
    for($i=0; $i < $count; $i++)
    {
        //$childCount = count($result[$i]);
        //for($j=0; $j < $childCount; $j++)
        //{
            print_r($result[$i]['jam']);
            echo "\n";
        //}
    }
}