mercoledì 8 giugno 2011

3csia.php

<html>
<head>
<title>Lettura dei dati in un file di testo</title>
</head>
<body>
<center>
<h2>Elenco della classe 3 C S.I.A.</h2>
<?php
//Apertura del file da usare
$fp=fopen("3csia.txt","r");
if($fp) {

//feof=file end of file
echo "table border='1'>";
while (!feof($fp)) {
$riga=fgets($fp,100);
$cognom="";
for ($i=0;$i<strlen($riga);$i++) {
if (substr($riga,$1,1)<>"|") {
$cognom=$cognom . substr($riga,$i,1);
echo "$cognom<br>";
}
else $i=strlen($riga);
}
echo "<tr><td>$cognom</td></tr>";
}
echo "</table>";
}
//chiusura del file aperto
fclose($fp);
}
else
echo "Il file non &egrave; stato trovato.";
?>
</center>
</body>
</html>

Nessun commento:

Posta un commento