PHP将CSV文件转换为数组并相交

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?

If the files aren't too big, you can load them into an array and either check that such value doesn't exist in the array before adding to it, or running array_unique() when you're done. See this for a reference.

If the files are too big, you'll have to use some other more complicated and time-consuming methods (such as reading the (hopefully sorted) output each time before inserting new line).