![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
27/05/2009, 09:01
|
| | Fecha de Ingreso: agosto-2007
Mensajes: 248
Antigüedad: 17 años, 5 meses Puntos: 1 | |
Respuesta: Escribir Array en Fichero CSV La solucion es la siguiente:
Código:
$separador=';'; //Los ficheros CSV tienen como separador ";"
//Open for reading and writing. Deletes content and overwrites the file.
$fichero=fopen($nombrefichero, "wb+");
$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 ++)
{
//fwrite devuelve el numero de bytes escritos
$numbytes = fwrite ($fichero,$cabecera_fichero[$i]);
}
fwrite ($fichero,"\r\n"); //Salto de Linea
}
fclose($fichero); //Cerramos Fichero
|