title: Pass array from controller to view - Codeigniter
body: <p>I tried to print the array in the controller, before passing it to a view and this is the output</p>
  
  <pre><code>Array ( [annunci] =&gt; Array ( [0] =&gt; stdClass Object ( [EmailDatore] =&gt; you@welcom.it [Nome] =&gt; asdasd [Cognome] =&gt; asdas [IdAnnuncio] =&gt; 9 [Titolo] =&gt; sfsdfdsfshrea [Testo] =&gt; agrefdgdagdfg [Categoria] =&gt; [Sede] =&gt; [TipoContratto] =&gt; [Add_Date] =&gt; [Drop_Date] =&gt; ) 
  [1] =&gt; stdClass Object ( [EmailDatore] =&gt; you@welcom.it [Nome] =&gt; asdasd [Cognome] =&gt; asdas [IdAnnuncio] =&gt; 10 [Titolo] =&gt; fafa [Testo] =&gt; fafaerea asdasdas dafasfd [Categoria] =&gt; [Sede] =&gt; [TipoContratto] =&gt; [Add_Date] =&gt; [Drop_Date] =&gt; ) ) )
  </code></pre>
  
  <p>I get the array from this method in my maincontroller</p>
  
  <pre><code> public function get_annunci(){
  
  
      $query=$this-&gt;user_model-&gt;annunci($this-&gt;email);        
      print_r($query);        
      }
  </code></pre>
  
  <p>I would like to pass this array to a view and then read the data. So i rewrite my method like this</p>
  
  <pre><code>public function get_annunci(){
      $query=$this-&gt;user_model-&gt;annunci($this-&gt;email);        
      $this-&gt;load-&gt;view('main_view',$query);      
  }
  </code></pre>
  
  <p>In main view i have this</p>
  
  <pre><code>&lt;div class="tab-pane active" id="annunci"&gt;
      &lt;ul&gt;
          &lt;?php
          print_r($annunci);
          ?&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my error</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Undefined variable: annunci
  
  Filename: views/tab_annunci_view.php
  
  Line Number: 4
  </code></pre>