$data = array('first_name' => $this->input->post('fname'),
'middle_name' => $this->input->post('mname'),
'last_name' => $this->input->post('lname'),
'email_name' => $this->input->post('email'),
'pwd_name' => $this->input->post('pwd'),
'cno_name' => $this->input->post('cno'),
'gender_name' => $this->input->post('gender'),
'country_name' => $this->input->post('country'),
'lang_name' => $this->input->post('lang')
);
echo $data;
我想回显或打印$ data,但它显示错误Severity:Notice
消息:数组到字符串转换
答案 0 :(得分:3)
方法1
foreach($data as $key => $val)
echo($key.' => '.(is_array($val)?implode(',', $val):$val).'<br>');
方法2
var_dump($data);
方法3
print_r($data);
答案 1 :(得分:0)
1)您尝试回显数组变量($ data)
2)您无法将 echo 用于数组变量
<强>溶液强>
3)您可以使用 var_dump($ data)或 print_r($ data)。
答案 2 :(得分:0)
$data = array('first_name' => $this->input->post('fname'),
'middle_name' => $this->input->post('mname'),
'last_name' => $this->input->post('lname'),
'email_name' => $this->input->post('email'),
'pwd_name' => $this->input->post('pwd'),
'cno_name' => $this->input->post('cno'),
'gender_name' => $this->input->post('gender'),
'country_name' => $this->input->post('country'),
'lang_name' => $this->input->post('lang')
);
foreach($data as $key => $value)
{
echo $key." has the value". $value;
}
$string=implode(",",$data);
echo $string;