title: codeigniter passing array data from model to controller
body: <p>I'm executing the following query in the get_distribuidor() function of my model:</p>
  
  <pre><code>public function get_distribuidor()
  {
      $this-&gt;load-&gt;helper('url');
  
      $query = $this-&gt;db-&gt;query("SELECT * FROM distribuidor where id_distribuidor='1';");
  
      foreach ($query-&gt;result_array() as $row)
      {
        echo $row['id_distribuidor'];
        echo $row['nome_empresa'];
        echo $row['cod_postal'];
        echo $row['localidade'];
        echo $row['telefone'];
        echo $row['fax'];
        echo $row['email'];
      }
  
  
      $res = array(
          'nome_empresa' =&gt; $row['nome_empresa'],
          'morada' =&gt; $row['morada'],
          'cod_postal' =&gt; $row['cod_postal'],
          'localidade' =&gt; $row['localidade'],
          'telefone' =&gt; $row['telefone'],
          'fax' =&gt; $row['fax'],
          'email' =&gt; $row['email']
      );
  
      return $res;
  
  }
  </code></pre>
  
  <p>Now, returning $res to the controller, i don't know very well how to separate the multiple fields the array result contains.</p>
  
  <p>I'm using this on a function of the controller:</p>
  
  <pre><code>$data['nome_produto']=$this-&gt;fichas_model-&gt;set_fichas();
  
  $teste=$this-&gt;fichas_model-&gt;get_distribuidor();
  
  $this-&gt;load-&gt;view('produtos/ponto1',$data, $teste);
  </code></pre>
  
  <p>to write on the view something like this:</p>
  
  <pre><code>&lt;input type="input" name="morada" value="&lt;?php echo $teste['morada'];?&gt;" /&gt;&lt;br /&gt;
  </code></pre>
  
  <p>but it's not working, can someone point me what am I doing wrong?</p>