Re: Modificar archivo.
| From: | Jose OLIVEIRA | Date: | Thu, 26 Oct 2000 16:30:09 +0000 |
| Subject: | Re: Modificar archivo. | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-2761@lists.php.net to get a copy of this message | ||
>Abro un archivo (fopen) con la conf: r+.
>Busco una cadena y la encuenta.Ahora la pregunta, una vez encontrada una
>cadena, como hago para sustituirla sin agregar una nueva linea, este
>archivo es de tipo texto. Cuando le hago un fput, me agrega la linea.
hola jose,
yo hago el update de mis ficheros planos de "bases de datos" de la siguiente manera:
muevete hasta la linea...
fseek($p_file, $OFFSET);
y sustituyela:
fwrite($p_file, $new_line);
int fseek(int fp, int offset);
Sets the file position indicator for the file referenced by fp
to offset bytes into the file stream. Equivalent to calling (in C)
fseek( fp, offset, SEEK_SET ).
int fwrite(int fp, string string, int [length]);
fwrite() writes the contents of string to the file stream
pointed to by fp. If the length argument is given, writing will
stop after length bytes have been written or the end of string
is reached, whichever comes first.
saludos,
josevi
-------------------------------------------------------------
Jose Vicente Oliveira - Steria Ingenierie et Telecom
12, rue Paul Dautier - BP 58 - 78142 Velizy Cedex - France