rudzis Posted August 4, 2004 Report Share Posted August 4, 2004 Man vajadziigs lai vienaa lapaa no *.txt failinja inkluudotu piem. piermaas 15 rindinjas t.i. starp /n (newline) simboliem. Der arii sarezgiitaaks skripts, lai dala pa lapaam, bet pietiks arii ar sho pashu... un veel... ... kaa lai dabuu gatavu, ka infa txt failam pievienojas no augshas t.i. lai kursors buutu priekshaa, bet iepriekshheejaa informaacija netiktu aizstaata. Lai viss vienkaarshi kraajas no augsgala. Tad /n vajag likt saakumaa nevis aizmuguree??? Link to comment Share on other sites More sharing options...
rnc Posted August 4, 2004 Report Share Posted August 4, 2004 Man vajadziigs lai vienaa lapaa no *.txt failinja inkluudotu piem. piermaas 15 rindinjas t.i. starp /n (newline) simboliem. Der arii sarezgiitaaks skripts, lai dala pa lapaam, bet pietiks arii ar sho pashu... <?php $f = file('lala.txt'); for ($i=0;$i<=14;$i++) { echo $f[$i].'<br>'; } ?> ... kaa lai dabuu gatavu, ka infa txt failam pievienojas no augshas t.i. lai kursors buutu priekshaa, bet iepriekshheejaa informaacija netiktu aizstaata. Lai viss vienkaarshi kraajas no augsgala. Tad /n vajag likt saakumaa nevis aizmuguree??? Raksti tāpat faila beigās, bet kad nolasi, tad apgriez otrādāk. Apskaties f-ju array_reverse(); :-) Link to comment Share on other sites More sharing options...
Venom Posted August 5, 2004 Report Share Posted August 5, 2004 (edited) a) $lines=file($file); echo '<ol><li>'.implode('</li><li>',$lines).'</li></ol>'; B) $fp=fopen($file,'r+'); fwrite($fp,"rindiņa\n"); 'r+' Open for reading and writing; place the file pointer at the beginning of the file. Edited August 5, 2004 by Venom Link to comment Share on other sites More sharing options...
Roze Posted August 5, 2004 Report Share Posted August 5, 2004 Man vajadziigs lai vienaa lapaa no *.txt failinja inkluudotu piem. piermaas 15 rindinjas t.i. starp /n (newline) simboliem. Der arii sarezgiitaaks skripts, lai dala pa lapaam, bet pietiks arii ar sho pashu... <? echo implode('<br/>',array_slice(file('fails.txt'),0,15)); ?> Ja gribi lai teiksim nakoshajaa lapaa buutu nakoshaas 15 rindinjas 0 vietaa liec 14/ tad 28 utt.. proti ja $lapa ir nododamais parametrs tad var ja teiksim saakam ar 1 ($lapa - 1) * 14 vai ja ar 0 lapu tad nevajag -1 Link to comment Share on other sites More sharing options...
rudzis Posted August 5, 2004 Author Report Share Posted August 5, 2004 Kaads neveeleetos uzrakstiit piemeeru ar array reverse? Link to comment Share on other sites More sharing options...
Venom Posted August 5, 2004 Report Share Posted August 5, 2004 Manuāļa nav? $lines=file($file); $lines=array_reverse($lines); $perpage=15; echo '<ol><li>'.implode('</li><li>',array_slice($lines,(int)$_GET['page']*perpage,$perpage)); Link to comment Share on other sites More sharing options...
Venom Posted August 5, 2004 Report Share Posted August 5, 2004 Manuāļa nav? $lines=file($file); $lines=array_reverse($lines); $perpage= Link to comment Share on other sites More sharing options...
Recommended Posts