$array = [];

foreach(test) {
  $operation=$db->prepare();
  $statu=$operation->execute();
  if ($statu) {
    $array[] = $id;
    $success = "İşlem başarıyla gerçekleşti.";
  } else {
    $error = "Bir hata oluştu.";
  }
}