Jump to content
php.lv forumi

Kā nolasīt datus no txt


janchuxss

Recommended Posts

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

Š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

×
×
  • Create New...