Не уверен, что вы подразумеваете под поиском по таблице, но чтобы открыть оба файла и что-то с ними делать:
$file1 = fopen("/path/to/file1.txt","r"); //Open file with read only access
$file2 = fopen("/path/to/file2.txt","r");
$combined = fopen("/path/to/combined.txt","w"); //in case you want to write the combined lines to a new file
while(!feof($file1) && !feof($file2))
{
$line1 = trim(fgets($file1)); //Grab a line of the first file, note the trim will clip off the carriage return/new line at the end of the line, can remove it if you don't need it.
$line2 = trim(fgets($file2)); //Grab a line of the second file
$combline = $line1 . $line2;
fwrite($combined,$combline . "\r\n"); //Write to new combined file, and add a new carriage return/newline at the end of the combined line to replace the one trimmed off.
//You can do whatever with data from $line1, $line2, or the combined $combline after getting them.
}
Примечание: у вас могут возникнуть проблемы, если вы столкнетесь с концом файла на одномДля файла перед другим, что может произойти, только если они не имеют одинаковую длину, могут потребоваться некоторые операторы control, чтобы установить $ line1 или $ line2 на ""
, или что-то еще, если feof()
их соответствующие файлы, как только оба попадутконец файла, цикл while завершится.