title: How can I read contents of a text file using PHP & process elements?
body: <p>I'm trying to read in a name from a text file in PHP and remove spaces in the names, which I do using preg_replace in a function. </p>
  
  <pre><code>function fixName($input) {
  $input = preg_replace('/[^ \w-]/', ' ', $input);
  return $input;
  }
  
  echo fixName('BOB     VAN'), "\n";
  </code></pre>
  
  <p>However, I have a text file that has multiple names similar to the one above each on a new line, and I'm trying to figure out how to store those names that are read in from the file and process and output them. Would I do something such as reading the file and storing them into an array?</p>
  
  <p>The text file looks like this</p>
  
  <pre><code>ID    FIRST    LAST
  348    BOB      VAN
  349    ALBERT      JOHN
  </code></pre>