Reputation: 13
$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;
i want to echo or print $data, but it showing error Severity: Notice
Message: Array to string conversion
Upvotes: 1
Views: 782
Reputation: 2176
Method 1
foreach($data as $key => $val)
echo($key.' => '.(is_array($val)?implode(',', $val):$val).'<br>');
Method 2
var_dump($data);
Method 3
print_r($data);
Upvotes: 3
Reputation: 302
$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;
Upvotes: 0
Reputation: 12085
1) your trying to echo the array variable ($data)
2) your not able to use echo for array variable
solution:
3) you can use var_dump($data) or print_r($data).
Upvotes: 0