I made the first form following the example put in the original question, repeating the value. Already doubted that it was this, but I answered anyway. There are simpler ways to do this.
The second is the way to do what you really want, according to the comments and editing of the question. And the third is the simplified way to get the same result.
//solução baseada na pergunta original
$tam = 4;
$minhastring = '';
$valor = 'teste';
for($i = 0; $i < $tam; $i++){
$minhastring .= $valor . ',';
}
$minhastring = substr($minhastring, 0, -1);
echo $minhastring . "\n";
//solução para a pergunta real
$minhastring = '';
$valor = Array('teste0', 'teste1', 'teste2', 'teste3');
$tam = count($valor);
for($i = 0; $i < $tam; $i++){
$minhastring .= $valor[$i] . ',';
}
$minhastring = substr($minhastring, 0, strlen($minhastring) - 1);
echo $minhastring . "\n";
//a mesma solução com função pronta - recomendada
$minhastring = implode($valor, ",");
echo $minhastring;
See working on ideone .