Questo è il codice completo:

<?php

#function wpsb_options() {
global $wpdb;
$table_users = $wpdb->prefix . "wpsb_users";
?>
<div class="wrap">
<h2>CSV FileCreator per la Newsletter</h2>








<?
if(!$_POST['a']){
?>


Clicca sul bottone sottostante per generare il file</p>
<form method="post" action="">

<p class="submit">
<input type="hidden" name="a" value="Crea il" />
<input type="submit" name="Submit" value="Crea il file csv &raquo;" />

</p>
</form>
<?
}else{
if ($users = $wpdb->get_results("SELECT * FROM $table_users ORDER BY `id` ASC")) {
$e=1;
foreach ($users as $user) {
$arr=split('#',$user->custom_data);
for($i=0; $i<10;$i++){
$arr[$i]=substr($arr[$i], 2);
}
if($arr[2]==''){$export.="\n";} else {$export.="$arr[2],";} //nome


$export.="$arr[4],"; //cognome
if($arr[6]!='') {$export.="$arr[6],";} //tel
$export.="$user->email"; //mail 1 OK (c'è sempre)
if($arr[8]==''){$export.="\n";} else {$export.=",$arr[8]";} //mail 2 OK (può non esserci)





$e++;
}
$path= $_SERVER['DOCUMENT_ROOT']."/wp-content/plugins/wpsb-create-csv/";
$file=$path."listaIscrittiNewsletter.csv";
$apro=fopen($file,"w");
if(fwrite($apro,$export)){
echo "<h2>File scritto con successo</h2>";
echo "

Puoi scaricare il file al percorso: ../listaIscrittiNewsletter.csv</p>

</p>";
}else{
echo"<h2>Errore in scrittura</h2>";
}
fclose($apro);
}
}
?>
</div>
<div class="wrap">









<h2>Tabella dei dati degli iscritti</h2>


</p>
<?php

if ($users = $wpdb->get_results("SELECT * FROM $table_users WHERE `msg_sent` = '1' ORDER BY `id` DESC")) {
?>
<h3>Bcc friendly format:</h3>



<?php
$additional_user=0;
foreach ($users as $user) {
if ($user->msg_sent == "1") {
if ($additional_user) {
echo ', ';
}
$additional_user=1;
echo $user->email;
}
}
?>
</p>
<?php
}
if ($users = $wpdb->get_results("SELECT * FROM $table_users ORDER BY `id` DESC")) {
$user_no=0;
$url = get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=' .
basename(__FILE__);
?>
<table class="widefat">
<thead>
<tr align="right">
<td colspan="6">
</td>
</tr>
<tr>
<th scope="col">ID</th>
<th scope="col">Nome</th>
<th scope="col">Cognome</th>
<th scope="col">E-mail1</th>
<th scope="col">E-mail2</th>
<th scope="col">Telefono</th>
</tr>
</thead>
<tbody>
<?php
$url = $url . '&amp;user_id=';
foreach ($users as $user) {
if ($user_no&1) {
echo "<tr class=\"alternate\">";
} else {
echo "<tr>";
}
$arr=split('#',$user->custom_data);
for($i=0; $i<10;$i++){
$arr[$i]=substr($arr[$i], 2);
}
#echo ($arr[2]." ___ ".$arr[4]." ___ ".$arr[6]." ___ ".$arr[8]);
$user_no=$user_no+1;
echo "<td>$user->id</td>";
echo "<td>" . $arr[2] . "</td>";
echo "<td>".$arr[4]."</td>";
echo "<td>$user->email</td>";
echo "<td>".$arr[8]."</td>";
echo "<td>".$arr[6]."</td>";
echo "</tr>";
}
?>
</tbody>
</table>


ToolTip: to insert the module in a page: 1) install the exec php plugin; 2) insert this code in your pages: &lt;?php wpsb_opt_in(); ?&gt;</p></div>
<?php
}

?>
ho modificato in questo modo:

if($arr[2]!=''){$export.="$arr[2],";} //nome
if($arr[2]!=''){$export.="$arr[4],";} //cognome
if($arr[6]!=''){$export.="$arr[6],";} //tel
$export.="$user->email"; //mail 1 OK (c'è sempre)
if($arr[8]==''){$export.="\n";} else {$export.=",$arr[8]";} //mail 2 OK (può non esserci)

ma il risultato non cambia, ovvero viene stampato in questo modo l'output:

nome,
cognome,
tel,
mail1,mail2..

es:

Salvatore
,Zedda
,345667788
,salvatore.zedda@tin.it,skip@skip.it


non capisco perchè mail1 e mail 2 vengano stampati affiancati proprio come voglio io mentre dopo nome , cognome e tel va a capo... qual'è il motivo??