Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/05/2009, 04:56
superdober
 
Fecha de Ingreso: agosto-2007
Mensajes: 248
Antigüedad: 16 años, 8 meses
Puntos: 1
Escribir Array en Fichero CSV

Tengo el siguiente codigo en el que quiero escribir un array en un fichero CSV pero no me escribe nada, alguna ayuda o guia por favor.. Gracias ¡¡¡

Código:
//Los ficheros CSV tienen como separador ";"
$separador=';'; 
//Abrimos para escribir y añadir, si no existe se crea el fichero
fopen($nombrefichero, "wa");  

$cabecera_fichero=array('REFERENCIA',$separador,'DESTINATARIO',$separador,'DOMICILIO',$separador,'POBLACION',$separador,'CODIGO POSTAL',$separador,'BULTOS',$separador,'PESO',$separador,'OBSERVACIONES',$separador);

if (is_writable($nombrefichero)) 
{
   for( $i = 0; $i < count($cabecera_fichero); $i ++)
    {
        fputcsv ($nombrefichero,$cabecera_fichero[$i]);        		
    }
}
fclose($nombrefichero);   //Cerramos Fichero

//Opcion al uaurio de Abrirlo o guardarlo directamente
header("Content-type: application/eml");
header("Content-Disposition: attachment; filename=".$nombrefichero."");