<?php
$tam = 4;
$minhastring = '';
$valor = 'teste';
for($i = 0; $i < $tam; $i++){
$minhastring .= $valor . ',';
}
$minhastring = substr($minhastring, 0, strlen($minhastring) - 1); echo $minhastring . "\n";
$minhastring = '';
$valor = Array('teste0', 'teste1', 'teste2', 'teste3'); for($i = 0; $i < $tam; $i++){
$minhastring .= $valor[$i] . ',';
}
$minhastring = substr($minhastring, 0, -1); echo $minhastring . "\n";
$minhastring = implode($valor, ","); echo $minhastring;
PD9waHAKJHRhbSA9IDQ7CiRtaW5oYXN0cmluZyA9ICcnOwokdmFsb3IgPSAndGVzdGUnOwpmb3IoJGkgPSAwOyAkaSA8ICR0YW07ICRpKyspewoKICAgICRtaW5oYXN0cmluZyAuPSAkdmFsb3IgLiAnLCc7Cn0KJG1pbmhhc3RyaW5nID0gc3Vic3RyKCRtaW5oYXN0cmluZywgMCwgc3RybGVuKCRtaW5oYXN0cmluZykgLSAxKTsKZWNobyAkbWluaGFzdHJpbmcgLiAiXG4iOwokbWluaGFzdHJpbmcgPSAnJzsKJHZhbG9yID0gQXJyYXkoJ3Rlc3RlMCcsICd0ZXN0ZTEnLCAndGVzdGUyJywgJ3Rlc3RlMycpOwokdGFtID0gc2l6ZW9mKCR2YWxvcik7CmZvcigkaSA9IDA7ICRpIDwgJHRhbTsgJGkrKyl7CiAgICAkbWluaGFzdHJpbmcgLj0gJHZhbG9yWyRpXSAuICcsJzsKfQokbWluaGFzdHJpbmcgPSBzdWJzdHIoJG1pbmhhc3RyaW5nLCAwLCAtMSk7CmVjaG8gJG1pbmhhc3RyaW5nIC4gIlxuIjsKJG1pbmhhc3RyaW5nID0gaW1wbG9kZSgkdmFsb3IsICIsIik7CmVjaG8gJG1pbmhhc3RyaW5nOw==
teste,teste,teste,teste
teste0,teste1,teste2,teste3
teste0,teste1,teste2,teste3