我在codeigniter中从模型到控制器访问2d数组数据,但我想将数据保存在变量中?

时间:2016-12-16 15:25:10

标签: php codeigniter

我的控制器功能:   function view_story($ story_id)

{
    $this->load->model('m_signup');
    $data['template_data'] = $this->m_signup->get_template($story_id);
    var_dump($data);
  // here i want  'template_name' so that it can save in variable.
}

我的输出

 array (size=1)
  'template_data' => 
     array (size=1)
        0 => 
           array (size=3)
          'bg_image' => string 'assets/img/marine/bubbles1.png' 
          'bg_sound' => string 'assets/img/old/old.mp3' (length=22)
           'template_name' => string 'Marine' (length=6)

1 个答案:

答案 0 :(得分:1)

你想要这样尝试......

 function view_story($story_id)
        {
            $this->load->model('m_signup');
            $template_data= $this->m_signup->get_template($story_id)->result_array();
            print_r($template_data);
        }