Skip to content

Instantly share code, notes, and snippets.

@evaldosantos
Created April 2, 2014 19:52
Show Gist options
  • Save evaldosantos/9941814 to your computer and use it in GitHub Desktop.
Save evaldosantos/9941814 to your computer and use it in GitHub Desktop.
<?php
$i=1;
//lerDiretorio("uploads", $i);
$file = "uploads";
$o = "teste.txt";
lerDiretorio($file, $o);
function lerDiretorio($dirname, $todos)
{
$files = scandir($dirname);
foreach($files as $file)
{
if($file=="." || $file=="..") continue;
else if(is_dir($dirname."/".$file))
{
lerDiretorio($dirname."/".$file, $todos);
}
else
{
lerArquivo(realpath($dirname."/".$file), $todos);
}
}
}
function lerArquivo($upload_success, $otherFile)
{
$file_handle = fopen($upload_success, "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
$tipoLinha = substr($line, 0, 2);
if ($tipoLinha != '02' && $tipoLinha != '92') {
file_put_contents($otherFile, $line, FILE_APPEND);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment