title: How to filter the first occurrence with preg_match
body: <p>I'm trying to filter domains from a text file which appear always at first position on each line.</p>
  
  <p>File looks like:</p>
  
  <pre><code>Domains         Users
  domain1.com     User1
  domain2.com     User2
  domain3.com     User3
  </code></pre>
  
  <p>Thats what I tried:</p>
  
  <pre><code>preg_match_all('/^[^ ]+/', $file, $matches);
  </code></pre>
  
  <p>It is producing the following result:</p>
  
  <pre><code>array(1) {
    [0]=&gt;
    array(1) {
      [0]=&gt;
      string(6) "Domains"
    }
  }
  </code></pre>
  
  <p>It is taking the first line, but stops after it. Thats quite strange.</p>
  
  <p>Any help here is much appreciated.</p>
  
  <p>The other question I have is the following.
  What is faster, the first approche with preg_match or the following.</p>
  
  <pre><code>$lines = preg_split('/\r\n|\r|\n/', $file);
  
  foreach($lines as $line) {
      $parts = explode(' ', $line, 2);
      $domains[] = $parts[0];
  }
  </code></pre>