You can concatenate the string as @rray put in the comments:
$ids_ .= $id_inscrito .'|';
Remembering that you must initialize the $ids_
variable before the loop. Another point to consider is that the last id will always be followed by a |
character. A more complete solution would look like this:
$ids_ = '';
foreach (...) {
// codigo
// se o $ids_ não estiver vazio adiciona '|' antes do próximo id
$ids_ .= ($ids_ == '') ? $id_inscrito : '|' . $id_inscrito ;
}
Another possible way is to use arrays, as @HaroldoTorres put in your answer:
$ids_ = array();
foreach (...) {
// codigo
$ids_[] = $id_inscrito;
}
$ids_ = implode('|', $ids_);