title: Passing array from Controller to view in codeigniter
body: <p>hi I m new in mongodb and codeigniter I have try to make simple CRUD operation in
  mongodb and php codeigniter I m trying to pass my array from Controller to view but it could not be done it gives an error 
  A PHP Error was encountered</p>
  
  <p>Severity: Notice</p>
  
  <p>Message: Undefined variable: user_list</p>
  
  <p>Filename: views/show_user.php</p>
  
  <p>Line Number: 15</p>
  
  <p>here is my code for Controller </p>
  
  <pre><code>class user extends CI_Controller
  {
      public function __construct()
      {
           parent::__construct();
           //loading  the mongodb library
           $this-&gt;load-&gt;model('mongo_model');
      }
  
     //index where the controller starts
      public function index() 
      {
          $collection = $this-&gt;mongo_model-&gt;selectCollectiondb();
          $collection= iterator_to_array($collection);
          foreach ($collection as $users)
          {
          $data['_id']=$users['_id'];
          $data['firstname']=$users['firstname'];
          $data['lastname']=$users['lastname'];
          $data['email']=$users['email'];
          $data['password']=$users['password'];
          }
          print_r($data);
          $this-&gt;load-&gt;view('show_user',$data);
      }
  }
  </code></pre>
  
  <p>Code for view is</p>
  
  <pre><code>&lt;?php 
  print_r($user_list);
  exit();
  &lt;?php }?&gt;
  </code></pre>