title: Replace whitespace in array in PHP
body: <p>I have an index page that takes a user input list of items separated by a space. It processes that list as an array and replaces the white space with a ", ". However, my PHP script doesn't seem to do that and I'm not sure I understand why.</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;form action="process.php" method="post"&gt;
      &lt;b&gt;Enter a list of items separated by a space:&lt;/b&gt; &lt;br&gt;&lt;input name="list[]" type="text"&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>process.php</strong></p>
  
  <pre><code>&lt;?php
  $list = $_POST["list"];
  $list = preg_replace('#\s+#',', ',trim($list));
  echo "&lt;b&gt;Your listed items were:&lt;/b&gt; $list";
  
  ?&gt;
  </code></pre>
  
  <p>Any help in understanding this would be greatly appreciated! Thanks!</p>
  
  <p><strong>EDIT</strong>
  Thanks a lot everyone! Seems like my issue was a fairly novice one and fixing it was pretty easy.</p>