$chiavi=explode("," ,$_POST['cerca']); while (list(, $valore) = each ($chiavi)) { $valore = str_replace(" ", "", $valore); $elementi[] = $valore; }