如何在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');
}
答案 0 :(得分: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 ali