janchuxss Posted February 11, 2006 Report Share Posted February 11, 2006 Tātad lieta tāda, vēlētos uzzināt, kā nolasīt mainīgos no *.txt un parādīt $fp = fopen($file,"a"); fwrite($fp,'|'.$id.'|'.$name.'|'.$mail.'|'.$koment.'| '); fclose($fp); Šādi saglabā, bet kā nolasīt? :\ Link to comment Share on other sites More sharing options...
bubu Posted February 12, 2006 Report Share Posted February 12, 2006 Iesaku labāk rakstīt ar \n simbolu, nevis vienkārši | beigās. Tad varēs lasīt šādi: $f = file($file); foreach($f as $line) { list($id, $name, $mail, $koment) = explode('|', trim($line)); // ... // echo $id, $name, $mail, $koment; } Link to comment Share on other sites More sharing options...
v3rb0 Posted February 12, 2006 Report Share Posted February 12, 2006 + pirms rakstīšanas visus \n ar <br /> vai kaut ko citu aizvietot, lai vienam ierakstam viena rinda. Link to comment Share on other sites More sharing options...
ok1 Posted February 14, 2006 Report Share Posted February 14, 2006 Šitais no manuāļa: <?php $handle = @fopen("/tmp/inputfile.txt", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?> Link to comment Share on other sites More sharing options...
Recommended Posts