title: How to remove empty value of array
body: <p>i'm looking for a way to remove empty values from a array.</p>
  
  <p>If you see the code below, i'm trying to remove the empty values that get passed through before attaching it to the model. But this hasn't turned out this way so far.</p>
  
  <p>Ofcourse i searched the web before asking, and so i know that <code>trim()</code> doesn't give the desired effect aswell as <code>array_map()</code> and the code below.</p>
  
  <p>Looking for solutions, thanks!</p>
  
  <pre><code>if(Input::get('addcategorie'))
      {
          $new_cats = array();
          foreach(
              explode(
                  ',', Input::get('addcategorie')) as $categorie) 
          {
              $categorie = Categorie::firstOrCreate(array('name' =&gt; $categorie));
              foreach($new_cats as $newcat)
              if($newcat == ' ' || $newcat == '&amp;nbsp;' || $newcat == ''){
                  unset($newcat);
              }
              array_push($new_cats, $categorie-&gt;id);
          }
          $workshop-&gt;categories()-&gt;attach($new_cats); 
      }
  </code></pre>