title: Include a file into a variable
body: <p>I am trying to keep my code clean break up some of it into files (kind of like libraries).  But some of those files are going to need to run PHP.</p>
  
  <p>So what I want to do is something like:</p>
  
  <pre><code>$include = include("file/path/include.php");
  $array[] = array(key =&gt; $include);
  
  include("template.php");
  </code></pre>
  
  <p>Than in template.php I would have:</p>
  
  <pre><code>foreach($array as $a){
      echo $a['key'];
  }
  </code></pre>
  
  <p>So I want to store what happens after the php runs in a variable to pass on later.</p>
  
  <p>Using file_get_contents doesn't run the php it stores it as a string so are there any options for this or am I out of luck?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>So like:</p>
  
  <pre><code>function CreateOutput($filename) {
    if(is_file($filename)){
        file_get_contents($filename);
    }
    return $output;
  }
  </code></pre>
  
  <p>Or did you mean create a function for each file?</p>