且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将字符串与 PHP 中的字符串列表进行比较?

更新时间:2023-01-29 15:47:42

Well there is a more efficient way to achieve this. Using array_intersect you can find the common lines between this two files.

$a = file('file1.txt');
$b = file('file2.txt');
$c = array_intersect($a, $b);

Whatever lines which are common between the two files are found in the $c array. However do note that the intersection is case sensitive.