【问题标题】:I can't add data to chartjs from codeigniter我无法从 codeigniter 向 chartjs 添加数据
【发布时间】:2018-12-20 09:13:42
【问题描述】:

如何在 codeigniter 框架中为 $info['data'] 编码 json

public function chartjs(){
        $info['title'] = 'Chartjs';
        $info['data'] = $this->post_model->get_posts();
        $this->load->view('templates/header');
        $this->load->view('chartjs',$info);
        $this->load->view('templates/footer');
    }

【问题讨论】:

    标签: php json codeigniter chart.js codeigniter-3


    【解决方案1】:

    // 这是为 $info['data'] 编码 json 的编辑代码

    public function chartjs(){
            $info['title'] = 'Chartjs';
            $post_data = $this->post_model->get_posts();
            $info['data'] = json_encode($post_data);
            $this->load->view('templates/header');
            $this->load->view('chartjs',$info);
            $this->load->view('templates/footer');
        }
    

    我相信这段代码的帮助你可以正确编码 json。 谢谢, Kamiyab 阿里

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 2023-01-17
      相关资源
      最近更新 更多