do { if (strlen($_POST["tipo"][$i]) >0){ $msg=$msg.$_POST["tipo"][$i].","; } $i++;//nunca incrementaba el contador :( } while ($i < $n);