我收到有关“未定义偏移量 = 0”的警告。我究竟做错了什么?
这是我的控制器:
function document_data()
{
$this->load->library('upload');
$files = $_FILES;
$cpt = count($_FILES['userfile']['name']);
$tax_name=$this->session->userdata['doc_proff'];
$tax_cid=array();
foreach($tax_name as $key=>$value)
{
$tax_cid[]=$this->Tax_model->get_id($value);
}
foreach($tax_cid as $k=>$v) {
$new[$k] = $v[0];
}
//var_dump($k);die('gugu');
foreach($new as $k=>$v) {
$tax_id[$k] = $v['tax_id'];
}
//var_dump($v);die('gugu');
$this->upload->overwrite = true;
for($i=0; $i<$cpt; $i++)
{
$ext=explode(".", $files['userfile']['name'][$i]);
$file_name=$_POST["doc_title"][$i].".".$ext[1];
$_FILES['userfile']['name']= $file_name;
$_FILES['userfile']['type']= $files['userfile']['type'][$i];
$_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
$_FILES['userfile']['error']= $files['userfile']['error'][$i];
$_FILES['userfile']['size']= $files['userfile']['size'][$i];
$empid=$this->session->userdata['empid'];
$this->upload->initialize($this->set_upload_options());
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('doc_upload', $error);
}
$data=array(
'doc_status' => 1,
'doc_title' => $_POST["doc_title"][$i],
'doc_link' => $file_name
);
$this->Tax_model->update_tax_submit($empid,$data,$tax_id[$i]);
$this->session->set_flashdata('message', "<p>Data added successfully.</p>");
}
}
这是我的模型:
public function get_id($name)
{
$this->db->select('tax_id');
$this->db->where('tax_name',$name);
$query=$this->db->get('tax_saving');
return $query->result_array();
}
警告发生在我的控制器的以下行:
$new[$k] = $v[0];
一切似乎都运行良好。我只是想摆脱这个警告。我应该怎么办?