Using PHP to Merge Multiple CSV Files
<p>I'm new to this forum and also new to PHP, I'm building some very basic functions on a test site while I learn a little more about how to use PHP. One of the current project I'm experimenting with is combining two directories of CSV files.</p>

<p>I was hoping to use GLOB as sort of a *wildcard to gather up the files in each directory and then combine them. I know the way I'm using below isn't very memory efficient but this is just to learn with. The issue I'm having is setting the GLOB command to pickup all my CSV files and then getting that variable into a file_get_contents.</p>

<p>Here's my code..</p>

<pre><code>$files = glob("http://www.website.com/1/*.csv");
foreach($files as $filepath) {
  if ($handle = fopen($filepath, "r")) {
     // ...
  }
}
$files2 = glob("http://www.website.com/35/*.csv");
foreach($files2 as $filepath2) {
  if ($handle2 = fopen($filepath2, "r")) {
     // ...
  }
}
file_put_contents('final_data.csv',
    file_get_contents($files) .
    file_get_contents($files2)
);
</code></pre>