Skip to content

Instantly share code, notes, and snippets.

@mcjwsk
Created March 22, 2015 20:27
Show Gist options
  • Save mcjwsk/d84f41de1c04a3c0f078 to your computer and use it in GitHub Desktop.
Save mcjwsk/d84f41de1c04a3c0f078 to your computer and use it in GitHub Desktop.
<?php
error_reporting(-1);
ini_set('display_errors',1);
$iterator = new GlobIterator('dane/*.csv', FilesystemIterator::KEY_AS_FILENAME);
$data = iterator_to_array($iterator);
$j = 0;
foreach (array_keys($data) as $file) {
$content = file('dane/'.$file);
for($i =1; $i < count($content); $i++) {
$content[$i] = $file.';'.$content[$i];
}
if ($j > 0) {
unset($content[0]);
} else {
$content[0] = 'PLIK;'.$content[0];
}
//echo $file.'<br>';
file_put_contents('dane.csv', implode('', $content), FILE_APPEND);
$j++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment