title: Cant compare .txt files in php
body: <p>So I'm new to php and programming and I can't seem to find how I compare properly two text files.</p>
  <p>So basically I want to compare the first file with the second and I want to output the values that first file has that the second file doesn't have.</p>
  <p>This is the code that I have (UPDATED):</p>
  <pre><code>$data1 = file_get_contents($filename1);
  var_dump($data1);
  $data2 = file_get_contents($filename2);
      
  $n = -1;
  
  foreach($data1 as $line1){
      $line1 = trim($line1);
      
      if(strpos($data2, $line1) !== false){
          $n +=1;
          echo $n.&quot; - &quot;.$line1.&quot;&lt;br&gt;&quot;;
      } 
  }
  </code></pre>
  <p>I'm also using laravel framework and that's the reason why I have so variables that are not defined in that piece of code, they are defined in the controllers.</p>