title: CodeIgniter loading a view into a view
body: <p>I need to load a view into a view within CodeIgniter, but cant seem to get it to work.</p>
  
  <p>I have a loop. I need to place that loop within multiple views (same data different pages). So I have the loop by itself, as a view, to receive the array from the controller and display the data.</p>
  
  <p>But the issue is the array is not available to the second view, its empty</p>
  
  <p>The second view loads fine, but the array <code>$due_check_data</code> is empty</p>
  
  <p>SO, I've tried many things, but according to the docs I can do something like this:</p>
  
  <p>Controller:</p>
  
  <pre><code>// gather data for view
  
  $view_data = array(
     'loop' =&gt; $this-&gt;load-&gt;view('checks/include/due_checks_table', $due_check_data, TRUE),
     'check_cats' =&gt; $this-&gt;check_model-&gt;get_check_cats(),
     'page_title' =&gt; 'Due Checks &amp; Tests'
  );
  
  $this-&gt;load-&gt;view('checks/due_checks',$view_data);
  </code></pre>
  
  <p>But the array variable <code>$due_check_data</code> is empty</p>
  
  <p>I'm just getting this error, saying the variable is empty?</p>
  
  <blockquote>
    <p>Message: Undefined variable: <code>due_check_data</code></p>
  </blockquote>