Syntax of a wrong PHP fix

0

I have a little syntax error with a php fix (I'm a newbie in php), it happens that I need to send my form the load of 2 different tables to 2 select, both models work for me, and each probe and if the load. But sending both inside an array does not work for me. I get unexpected syntax error '=' waiting ')'. I have tried the arrangement in different ways but it does not work for me. HELP PLEASE

public function registroC()
{
    $data['titulo'] = 'Registrar Ciudadano';

    $datos = array(
        ['localidades'] = $this->Registros_model->mostrarloc(),
        ['colonias'] = $this->Registros_model->mostrarcol());

    $this->load->view('plantillas/header', $data);
    $this->load->view('registro', $datos);
    $this->load->view('plantillas/footerlog');
}
    
asked by RMustang 10.10.2017 в 19:50
source

1 answer

2
  

According to the definition you want to apply, it should look like this

public function registroC()
{
    $data['titulo'] = 'Registrar Ciudadano';

    $datos = array(
      'localidades' => $this->Registros_model->mostrarloc(),
      'colonias'    => $this->Registros_model->mostrarcol()
    );

  $this->load->view('plantillas/header', $data);
  $this->load->view('registro', $datos);
  $this->load->view('plantillas/footerlog');
}
  

Otherwise you can apply the following syntax

public function registroC()
{
  $data['titulo'] = 'Registrar Ciudadano';

  $datos['localidades'] = $this->Registros_model->mostrarloc();
  $datos['colonias']    = $this->Registros_model->mostrarcol();

  $this->load->view('plantillas/header', $data);
  $this->load->view('registro', $datos);
  $this->load->view('plantillas/footerlog');
}
  

The two forms should cause the same effect.

     

Greetings.

    
answered by 10.10.2017 / 20:22
source