php
This commit is contained in:
48
Practicas/Practicas_PHP/ejercicios/Ejercicio7_04_Tabla.php
Normal file
48
Practicas/Practicas_PHP/ejercicios/Ejercicio7_04_Tabla.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Ejercicio7_04_Tabla</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
||||
$nombre_archivo = "formularios/usuarios.txt";
|
||||
$contenido = file_get_contents($nombre_archivo);
|
||||
|
||||
$lineas = array();
|
||||
$archivo = fopen($nombre_archivo, 'r');
|
||||
|
||||
while (($linea = fgets($archivo)) !== false) {
|
||||
$lineas[] = $linea;
|
||||
}
|
||||
|
||||
fclose($archivo);
|
||||
|
||||
echo '<table border="2">
|
||||
<tr>
|
||||
<th># Index</th>
|
||||
<th>Nombre</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
<tbody>';
|
||||
foreach ($lineas as $index => $linea) {
|
||||
$contenido_linea = explode(" - ", $linea);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $index + 1 . '</td>';
|
||||
foreach ($contenido_linea as $contenido) {
|
||||
echo '<td>' . $contenido . '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody>
|
||||
</table>';
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user