abc
abc

Reputation: 87

implode() :invalid argument passed

function submit_data()
    {
        $st_value='';
        $ft_value='';
        $mt_value='';
        $otr_value='';
        $st_details= $this->input->post('check_list');  
        $ft_details= $this->input->post('ft_check_list');  
        $mt_details= $this->input->post('mt_check_list');  
        $otr_details= $this->input->post('otr_check_list');  
        //print_r($st_details);
        $st_value=implode(",",$st_details);
        $ft_value=implode(",",$ft_details);
        $mt_value=implode(",",$mt_details);
        $otr_value=implode(",",$otr_details);

        $index= $this->register->insert_details($st_value,$ft_value,$mt_value,$otr_value); 
        //$this->register->update_details($st_value,$ft_value,$mt_value,$otr_value);

        $this->session->set_flashdata('success_message',$success_message);
        redirect(base_url().'new_register/index/'.$index);  

    }

Here is my controller function and i am getting an error message of implode(): invalid argument passed while submiting,How can i intercept the error.

Upvotes: 0

Views: 551

Answers (2)

Bojan Radaković
Bojan Radaković

Reputation: 440

As others said, implode() uses second parameter as array. You can test your varriable to see if it's an array using is_array() or using var_dump() to see its details.

implode()

is_array()

var_dump()

Upvotes: 2

Aniket Singh
Aniket Singh

Reputation: 2634

implode() method accept second parameter as array. I think you are providing it a string. Check by var_dump($st_details);

Upvotes: 2

Related Questions