Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从codeigniter中的控制器发送两个数据数组以查看_Php_Codeigniter - Fatal编程技术网

Php 从codeigniter中的控制器发送两个数据数组以查看

Php 从codeigniter中的控制器发送两个数据数组以查看,php,codeigniter,Php,Codeigniter,我想从我的控制器发送两个数据阵列,以查看如何执行此操作? 下面是我的控制器代码 class Home extends CI_Controller { public function box() { $url = $this->pageURL(); $id_from_url = explode('/', $url); $id = $id_from_url[6]; $query = $this->db->get_where('mc_boxes',

我想从我的控制器发送两个数据阵列,以查看如何执行此操作? 下面是我的控制器代码

class Home extends CI_Controller {
 public function box() {
    $url = $this->pageURL();
    $id_from_url = explode('/', $url);
    $id = $id_from_url[6];
    $query = $this->db->get_where('mc_boxes', array('idmc_boxes' => $id));
    $row = $query->row();
    $rowcount = $query->num_rows();
    if ($rowcount <= 0) {
        echo 'ID not found';
    } else {
        $box_id = $row->idmc_boxes;
        $customer_id = $row->customers_idcustomers;
        $language_id = $row->languages_idlanguages;
        $template_id = $this->getTemplateID($box_id);
        $template_data = $this->getTemplateData($template_id);
        $variables_data = $this->getVariables($customer_id, $language_id);
        $title = $variables_data[0]['value'];
        $this->load->view('template', $template_data);
    }
  }
}
class Home扩展CI_控制器{
公共功能盒(){
$url=$this->pageURL();
$id_from_url=explode(“/”,$url);
$id=$id_from_url[6];
$query=$this->db->get_-where('mc_-box',数组('idmc-u-box'=>$id));
$row=$query->row();
$rowcount=$query->num_rows();
如果($rowcount idmc_盒;
$customer\u id=$row->customers\u id客户;
$language\u id=$row->languages\u id语言;
$template\u id=$this->getTemplateID($box\u id);
$template\u data=$this->getTemplateData($template\u id);
$variables\u data=$this->getVariables($customer\u id,$language\u id);
$title=$variables_data[0]['value'];
$this->load->view('template',$template\u data);
}
}
}
在我的模板视图中,当我回显$title时,它会说它未定义 如何使用$template\u数据数组发送整个$variables\u数据数组


谢谢:)

不要使用每个数组,而是将所有数组都设置为一个

像这样,只给重要的部分

...................
$data['template_data'] =  $this->getTemplateData($template_id);

$data['variables_data'] =  $this->getVariables($customer_id, $language_id);

$data['title'] =  $variables_data[0]['value'];

$this->load->view('template', $data);

您可以在视图文件中获取$template_数据和$variables_数据

通常您传入的数据为:


$data['template_data'] =  $template_data;
$data['title'] =  $$title; 
....
$this->load->view('template', $data);

模板_数据是普通数组,变量_数据是多维数组如何在视图中获取特定的数组项?您可以在视图文件中迭代任何级别的数组。它在普通php页面中也会以同样的方式工作,非常感谢您的帮助和快速响应:)在做任何事情之前,不要忘记添加:$data=array();您应该查看用户指南,它非常全面: