title: php preg_match returns no result
body: <p>please correct me in my code. i have a txt file and contains the keywords.</p>
  
  <pre><code>example
  aaa
  aac
  aav
  aax
  asd
  fdssa
  fsdf
  </code></pre>
  
  <p>and I created a php file for search.</p>
  
  <pre><code>&lt;?php
  $file = "myfile.txt";
  if($file) {
      $read = fopen($file, 'r');
      $data = fread($read, filesize($file));
      fclose($read);
  
      $im = explode("\n", $data);
      $pattern = "/^aa+$/i";
  
      foreach($im as $val) {
          preg_match($pattern, $val, $matches);
      }
  }
  else {
      echo $file." is not found";
  }
  ?&gt;
  &lt;pre&gt;&lt;?php print_r($matches); ?&gt;&lt;/pre&gt;
  </code></pre>
  
  <p>this should return</p>
  
  <pre><code>aac
  aav
  aax
  </code></pre>
  
  <p>it should return a match word. if word has "aa" in from the left all words that has aa in the left will return back. and i want the result in array.
  how to do that? please help</p>