Argomenti

martedì 13 settembre 2011

lettura dati file di testo

<html>
<head>
<title>Lettura dei Dati in un file di testo</title>
<head>
<body>
<?php
//intestazione della tabella
echo "<table border='0' align=center>
<tr bgcolor=red>
<td><font face=Arial color=white>Dati Anagrafici</font></td>
</tr>";
//apertura dei file da usare
$fp=fopen("3csia.txt","r");
//controllo che il file esista
if($fp) {
while(!feof($fp)){
$riga=fgets($fp,100);
$cognom="";
for ($i=0;$i<strlen($riga);$i++) {
if (substr($riga,$i,1)<>"|") {
$cognom=$cognom . substr($riga,$i,1);
}
else $i=strlen($riga);
}
echo "<tr bgcolor=purple>
<td><font face=Arial color=white >$cognom</font></td>
</tr>";
} fclose ($fp);
echo"</table>";
}
else echo "il file non &egrave; stato trovato";
?>
</body>
</html>

Nessun commento:

Posta un commento