i'm looking for a way to remove empty values from a array.
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.
Ofcourse i searched the web before asking, and so i know that trim() doesn't give the desired effect aswell as array_map() and the code below.
Looking for solutions, thanks!
if(Input::get('addcategorie'))
{
$new_cats = array();
foreach(
explode(
',', Input::get('addcategorie')) as $categorie)
{
$categorie = Categorie::firstOrCreate(array('name' => $categorie));
foreach($new_cats as $newcat)
if($newcat == ' ' || $newcat == ' ' || $newcat == ''){
unset($newcat);
}
array_push($new_cats, $categorie->id);
}
$workshop->categories()->attach($new_cats);
}