$file_name = 'amzn.txt';
$fp = fopen($file_name,'w');
foreach($names as $n){
fputs($fp, $n. "\n");
}
fclose($fp);

– copyで amzn_cp.txt を作ります。
– file_get_contents()で中身を取得して比較
copy('amzn.txt', 'amzn_cp.txt');
// スクレイピング
$file_name = 'amzn.txt';
$fp = fopen($file_name,'w');
foreach($names as $n){
fputs($fp, $n. "\n");
}
fclose($fp);
$old = file_get_contents('amzn.txt');
$new = file_get_contents('amzn_cp.txt');
if($old !== $new){
echo "changed";
// 更新があった場合の処理
} else {
echo "not changed";
}
凄い単純だけど、これで良いのかな〜