• 1
Votes
name
name Punditsdkoslkdosdkoskdo

how to display array values in view using codeigniter

Controller:

function checkedServices() {

        $data = array();
        foreach($this->input->post('check_service') as $ser) {
            $data[] = array('service' => $ser);
        }

        $checked_services['services'] = array($data);

        $this->load->view('checked_services', $checked_services);
    }

view:

foreach($services as $ser)
    {   
        echo $ser;
    }

Output:

Severity: Notice

Message: Array to string conversion

Filename: views/checked_services.php

name
  • 1
Teacher

In Controller

function checkedServices() 
{

        $data = array();
        foreach($this->input->post('check_service') as $ser) {
            $data[]['service'] = $ser;
        }

        $checked_services['services'] = $data;

        $this->load->view('checked_services', $checked_services);
    }

In View

foreach($services as $ser)
{
  echo $ser['service'];
}
  • 1
Reply Report