Aktív témák
-
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. -
L3zl13
nagyúr
A file elejére nem igen tudsz írni, csak ha kiolvasod memóriában szerkeszted majd visszaírod.
-
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. -
LionTm
aktív tag
Annyire nem megy hogy így az üzenetet sem menti le :(
-
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?
-
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
-------------------------
Aktív témák
- AKCIJÓÓÓ!! Sosemhasznált! HP OmniBook 5 Flip i5-1334U 8GB 512GB 14" FHD+ áthajtós-érintős Gar.: 1 év
- Bomba ár! HP ProBook 430 G5 - i5-8GEN I 8GB I 128SSD I HDMI I 13,3" FHD I Cam I W11 I Garancia!
- ÁRGARANCIA!Épített KomPhone Ryzen 7 7800X3D 32/64GB RAM RTX 5090 32GB GAMER PC termékbeszámítással
- 188 - Lenovo LOQ (15IRX10) - Intel Core i5-13450HX, RTX 5060
- Xiaomi Mi 10T Pro 256GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
