PDA

Volledige versie bekijken : met php text boven aan textbestand toevoegen


sheikh
%Europe/Berlin %529 %2006, 13:42
hallo,
ik wil graag met php gegevens aan een text bestand toevoegen, alleen staan er al gegevens in. als ik het dan toevoeg komt het onder die text. nu wil ik alleen de laatste paar regels/tekens weergeven als ik het weer oproep in mijn pagina, hoe doe ik dit[?]

alvast bedankt,
greetz sheikh

brossiekoppie
%Europe/Berlin %659 %2006, 16:50
Je leest je data uit, voegt vanvoor je string eraan en je schrijft ze terug ;)

Of door je fopen aan te passen:

'r+' Openen voor lezen en schrijven; plaats de bestands pointer aan het begin van het bestand.

josko
%Europe/Berlin %941 %2006, 23:36
verder kan je best wat creatiever zijn :).
Als je bestanden kan schrijven, kan je ze ook uitlezen dacht ik zo :)

handler = fopen( file, r )
data = fread( handler, filesize( file )
MyText = string
MyText .= data

daar ook aan gedacht?

Ik weet dat het weinig toevoegd, aangezien de goeie oplossing is gegeven.

Maar ik zeg dit om je alvast op achterdeurtjes te richten, wat je blijkbaar nog niet gedaan hebt.

verder:
'r' Open for reading only; place the file pointer at the beginning of the file.
'r+' Open for reading and writing; place the file pointer at the beginning of the file.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.

brossiekoppie
%Europe/Berlin %675 %2006, 17:13
Nu heb je dezelfde uitleg dus 2 keer :D