I have six CSV files that I want to convert into individual arrays and then intersect those arrays to see all of the values that are similar in each. I have this so far:
$directory = "/csv/CSS_AUDIT/";
if (! is_dir($directory)) {
exit('Invalid directory path');
}
$files = array();
foreach (scandir($directory) as $file) {
if ('.' === $file) continue;
if ('..' === $file) continue;
$files[] = $file;
$row = 1;
if (($handle = fopen("/csv/CSS_AUDIT/$file", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($r=0; $r < $num; $r++) {
echo $data[$r];
if (!empty($data[$r]))
echo "
";
}
}
fclose($handle);
}
}
Right now it is looping through the files and giving me everything in one large array and I'm just kinda stuck. Any advice on how to achieve What I am trying to do?