title: PHP - Normalize user input array
body: <p>If have an array like this:</p>
  
  <pre><code>array
    0 =&gt; string '62 52, 53' (length=9)
    1 =&gt; string '54' (length=2)
  </code></pre>
  
  <p>It's from user input, and you never know how/what they enter ;)</p>
  
  <p>What I want in the end is this:</p>
  
  <pre><code>array
    0 =&gt; string '62' (length=2)
    1 =&gt; string '52' (length=2)
    2 =&gt; string '53' (length=2)
    3 =&gt; string '54' (length=2)
  </code></pre>
  
  <p>Here's how I do it:</p>
  
  <pre><code>  $string = implode(',', $array);
    $string = str_replace(', ', ',', $string);
    $string = str_replace(' ', ',', $string);
    $array = explode(',', $string);
  </code></pre>
  
  <p>Seems really clunky. Is there a more elegant way? One that maybe has better performance?</p>