Mi sono perso, se inserisco un altro parametro e l'invio della mail all'interno della funzione non mi invia nulla, sicuramente ho sbagliato qualcosa.

codice:
function showAnswers2($answers,$questions,$sendemail) { 


	for($x = 0; $x< count($answers); $x++) {
		if ($x % 2 == 0) { 
		 	$output = "<div class=\"qanda clear\">\n";
		} else { 
			$output = "<div class=\"qanda\">";
  		}
 	$output .= '<h4>Domanda' . ($x+1) . ': ' . $questions[$x] . '</h4>'; 
	$output .= "
  1. \n"; for ($y = 0;$y< count($answers[$x]); $y++) { if (($answers[$x][$y] === $answers[$x][0]) && (in_array($answers[$x][$y],$_SESSION['correct']))) { $output .= "<li class=\"correctuser\">{$answers[$x][$y]} (Corretta!)\n"; } else if ($answers[$x][$y] === $answers[$x][0]) { $output .= "<li class=\"correct\">{$answers[$x][$y]}\n"; } else if (in_array($answers[$x][$y],$_SESSION['wrong'])) { $output .= "<li class=\"wrong\">{$answers[$x][$y]} (Erratta!)\n"; } else { $output .= "
  2. {$answers[$x][$y]}\n"; } } $output .= "
</div>\n"; //echo $output; } //Invio email dei risultati $to = "xxx@xxx.it"; $subject = "Risultato quiz di $_SESSION[user]"; $message = "Nome: $_SESSION[user], "; $message .= "Codice Verifica: $_SESSION[codverifica] "; $message .= "Risultati: $sendemail "; $headers = "From: $_SESSION[email]". "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$message,$headers); }//Chiusura funzione
Ho tolto l'eco per non stampare a video i risultati e fare tutto internamente senza che l'utente veda a video, ho provato a mettere la variabile $output ma essendo un ciclo mi inseriva nella mail solo l'ultimo risultato e non tutto. In che punto dovrei inserire la funzione per inserire nella mail tutto il ciclo?

Grazie ancora per la disponibilità