Aktív témák
-
LionTm
aktív tag
}
$fp = fopen (''proba.txt'', ''a'');
fwrite ($fp, $proba);
fclose ($fp);
}
Az lenne a cél hogy ne a proba.txt alá írja hanem az elejére... remlélem érthető vagyok. Tud segíteni valaki egy sör ellenében ?
proba.txt
-------------------------
$ide jöjjön a következő $proba
$proba
$proba
$proba
-------------------------hm..hm..hm..
-
e-biza
őstag
arra is gondoltam,hogy kiolvasnád elöször a proba.txt egy tömbbe, majd a tömbhöz hozzáadod a $proba -t. az sem megy?
Liƒє is too short. - http://www.lowcostdomain.eu
-
LionTm
aktív tag
Annyire nem megy hogy így az üzenetet sem menti le :(
hm..hm..hm..
-
supercow
őstag
$fp = fopen (''proba.txt'', ''a'');
$elejere = fseek($fp, 0)
fwrite ($fp, $proba);
fclose ($fp);
fseek
(PHP 3, PHP 4 )
fseek -- Seeks on a file pointer
Description
int fseek ( resource handle, int offset [, int whence])
Sets the file position indicator for the file referenced by handle.The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence, whose values are defined as follows:
SEEK_SET - Set position equal to offset bytes.
SEEK_CUR - Set position to current location plus offset.
SEEK_END - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
If whence is not specified, it is assumed to be SEEK_SET.In nomine Pasta, et Fusilli, et Spaghetti Sancti. Ramen.
-
L3zl13
nagyúr
A file elejére nem igen tudsz írni, csak ha kiolvasod memóriában szerkeszted majd visszaírod.
Aki hülye, haljon meg!
-
supercow
őstag
úgy tűnik hogy mégsem jó az fseek() megoldás, de itt egy másik:
[L]http://www.phpfreaks.com/quickcode/code/150.php[/L]
function write_beg($filename, $data)
{
//Imports old data
$handle = fopen($filename, ''r'');
$old_content = fread($handle, filesize ($filename));
fclose($handle);
//Sets up new data
$final_content = $data.$old_content;
//Writes new data
$handle2 = fopen($filename, ''w'');
$finalwrite = fwrite($handle2, $final_content);
fclose($handle2);
}
Minden esetre érdekes, hogy ez kimaradt az alap dolgok közül.In nomine Pasta, et Fusilli, et Spaghetti Sancti. Ramen.
-
supercow
őstag
ezt a függvényt berakod magadnak valamelyik include-odba (copy-paste), aztán úgy hívod, meg, hogy :
$savanyucukor = write_beg(''proba.txt'', ''elso sorba!'');
vagyis a $data a szöveg amit be akarsz rakni, a $filename az meg.... nem is tudom... :DIn nomine Pasta, et Fusilli, et Spaghetti Sancti. Ramen.
Aktív témák
- Canva Pro előfizetés - 1 éves
- AKCIÓ! - STEAM kulcsok /Anuchard, Aragami, Children of Morta, stb. - 2024.04.17.
- Bontatlan - BATTLEFIELD 1 Collectors Edition - Játékszoftver nélkül
- Windows, Office licencek a legolcsóbban, egyenesen a Microsoft-tól - 2990 Ft-tól!
- Bitdefender Total Security 3év/3eszköz! - "Tökéletes védelem most kedvező áron..."
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: Ozeki Kft.
Város: Debrecen