title: remove whitespaces from text inside textarea
body: <p>I have a textarea and inside it, looping through a unserialized array.</p>
  
  <p>I am trying to take text inside of textarea, break the string into an array with new line spaces as a separator, and serialize the array and store back to database.</p>
  
  <p>But with these spaces, I am getting a whole string as a single array element.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>$items = unserialize($menu['lunch_items']);
  
  &lt;textarea name="items" class="editInput items form-control input-sm" style="display: none; resize: none;" rows="8" cols="60"&gt;&lt;?php foreach($items as $item) :?&gt;
  &lt;?php echo $item; ?&gt;
  &lt;?php endforeach; ?&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>Its output:</p>
  
  <pre><code>                      Rice
  Parbar Aalu saadheko bhuteko sab sab
  Mix Curry (for veg)
  Egg Curry (for non-veg)
  Mula koreko with sano kerau
  </code></pre>
  
  <p>This is how I accessed the textarea value:</p>
  
  <pre><code>var items = $(this).closest("tr").find('textarea[name="items"]').val();
  </code></pre>
  
  <p>Here's how I get and try to break it into array:</p>
  
  <pre><code>$items = $postValues['items'];
  print_r($items);
  
  $itemArr = preg_split('/\r\n|\r|\n/', $items);
  $itemArr1 = explode('\n', $items);
  print_r($itemArr);
  print_r($itemArr1);
  die();
  </code></pre>
  
  <p>Output in console:</p>
  
  <pre><code>Rice                                                            Parbar Aalu saadheko bhuteko sab sab                                                            Mix Curry (for veg)                                                         Egg Curry (for non-veg)                                                         Mula Koreko with sano kerau                         
  
  Array
  (
      [0] =&gt;                              Rice                                                            Parbar Aalu saadheko bhuteko sab sab                                                            Mix Curry (for veg)                                                         Egg Curry (for non-veg)                                                         Mula Koreko with sano kerau                         
  )
  Array
  (
      [0] =&gt;                              Rice                                                            Parbar Aalu saadheko bhuteko sab sab                                                            Mix Curry (for veg)                                                         Egg Curry (for non-veg)                                                         Mula Koreko with sano kerau                         
  )
  </code></pre>
  
  <p>What I want it to be:</p>
  
  <pre><code>Array
  (
     [0] =&gt; Rice
     [1] =&gt; Parbar Aalu sadheko bhuteko sab sab
     [2] =&gt; Mix Curry
      .
      .
  )
  </code></pre>
  
  <p>How do I properly strip white spaces keeping new line spaces intact, and break it into proper array?</p>