title: Dynamically include variables php
body: <p>I am trying to get figure this out and haven't been able to. I'm trying to create a function that will include different config files into the script when needed. I want to store all the variables in arrays and then use a function to include them.</p>
  
  <p>Example</p>
  
  <p>Config.php</p>
  
  <pre><code>$array = array(
  'var1' =&gt; 'something',
  'var2' =&gt; 'something else'
  );
  </code></pre>
  
  <p>uses.php</p>
  
  <pre><code>class uses{
  
        public static function file($directory, $file){
  
          if(is_dir($directory))
          {   
              if(is_file($directory.$file))
              {        
             include $directory.$file;
  
              }
              else
              {
               echo "File Not Found $directory$file";
              }
          }
          else
          {
             echo 'Dir Not Found';
          }
      }
  }
  </code></pre>
  
  <p>index.php after I've included uses the file</p>
  
  <pre><code>uses::file(Config.php);
  print_r($array);
  </code></pre>
  
  <p>I know if you include a file inside a function they won't reach past the scope of the function. This would be loaded in by an auto loader so I would be able to use it anywhere inside my script. </p>
  
  <p>Thanks in advance, if you need any more information please let me know.</p>