Php mettre un fichier texte en tableau
Fermé
xunil2003
Messages postés
761
Date d'inscription
mercredi 17 novembre 2004
Statut
Membre
Dernière intervention
24 mars 2024
-
Modifié par xunil2003 le 22/07/2012 à 15:04
xunil2003 Messages postés 761 Date d'inscription mercredi 17 novembre 2004 Statut Membre Dernière intervention 24 mars 2024 - 22 juil. 2012 à 22:15
xunil2003 Messages postés 761 Date d'inscription mercredi 17 novembre 2004 Statut Membre Dernière intervention 24 mars 2024 - 22 juil. 2012 à 22:15
A voir également:
- Php mettre un fichier texte en tableau
- Fichier rar - Guide
- Tableau croisé dynamique - Guide
- Fichier host - Guide
- Fichier iso - Guide
- Comment réduire la taille d'un fichier - Guide
2 réponses
xunil2003
Messages postés
761
Date d'inscription
mercredi 17 novembre 2004
Statut
Membre
Dernière intervention
24 mars 2024
14
Modifié par xunil2003 le 22/07/2012 à 22:21
Modifié par xunil2003 le 22/07/2012 à 22:21
bonjour,
Finalement j'ai fait comme ci-dessous mais dans le tableau l'affichage n'est pas ligne par ligne dans les colonnes "Ordre X10" "Macro" "Executé par". Le code ne comprend pas quand il y a un espace et passe directement a la ligne ci-dessous .
le fichier texte est comme ceci
Merci.
Finalement j'ai fait comme ci-dessous mais dans le tableau l'affichage n'est pas ligne par ligne dans les colonnes "Ordre X10" "Macro" "Executé par". Le code ne comprend pas quand il y a un espace et passe directement a la ligne ci-dessous .
le fichier texte est comme ceci
30/06/2012 - 19:06:25 - serveur - cm15 E1 bri 15 - e1-15% - Crontab 30/06/2012 - 19:08:12 - serveur - cm15 E1 off - aucun - Script bash 30/06/2012 - 22:38:17 - serveur - cm15 D8 off - Macro e5-off vers d8-off - Script bash 22/07/2012 - 21:17:12 - root - cm15 F2 on - f2-on - Aucun - Asterisk 22/07/2012 - 21:17:24 - root - cm15 F2 off - f2-off - Aucun - Asterisk 22/07/2012 - 21:17:12 - root - cm15 E1 on - e1-on - Aucun - Script bash 22/07/2012 - 21:17:24 - root - cm15 E1 off - e1-off - Aucun - Script bash
<?php // le fichier $fichier1 = '/home/serveur/Domotique/rapports/ordres/2012-07-rapport-ordres.log'; // declaration variable $villes //$villes='colone1'; // ouverture du fichier $fp=fopen($fichier1,'r'); while (!feof($fp)) { // lecture et decoupage des lignes à chaque ; $position=explode("- ",fgets($fp,255)); // $position dans la ligne commence à zero $date2.=$position[0]; $heure.=$position[1]; $user.=$position[2]; $ordre_x10.=$position[3]; $fichier2.=$position[4]; $macro.=$position[5]; $execute_par.=$position[6]; } // fermeture du fichier fclose($fp); ?> <table style="text-align: left; width: auto;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="vertical-align: top; width: 19px;">Date<br> </td> <td style="vertical-align: top; width: 19px;">Heure<br> </td> <td style="vertical-align: top; width: 19px;">User<br> </td> <td style="vertical-align: top; width: 50px;">Ordre x10<br> </td> <td style="vertical-align: top; width: 19px;">Fichier<br> </td> <td style="vertical-align: top; width: 19px;">Macro<br> </td> <td style="vertical-align: top; width: 19px;">Executé par<br> </td> </tr> <tr> <td style="vertical-align: top;width: 19px;"><br> </td> <td style="vertical-align: top;width: 19px;"><br> </td> <td style="vertical-align: top;width: 19px;"><br> </td> <td style="vertical-align: top;width: 50px;"><br> </td> <td style="vertical-align: top;width: 19px;"><br> </td> <td style="vertical-align: top;width: 19px;"><br> </td> <td style="vertical-align: top;width: 19px;"><br> </td> </tr> <tr> <td style="vertical-align: top;width: 19px;"><?php echo $date2; ?><br> </td> <td style="vertical-align: top;width: 19px;"><?php echo $heure; ?><br> </td> <td style="vertical-align: top;width: 19px;"><?php echo $user; ?><br> </td> <td style="vertical-align: top;width: 50px;"><?php echo "". $ordre_x10 ."<br/ >"; ?><br> </td> <td style="vertical-align: top;width: 19px;"><?php echo $fichier2; ?><br> </td> <td style="vertical-align: top;width: 19px;"><?php echo $macro; ?><br> </td> <td style="vertical-align: top;width: 19px;"><?php echo $execute_par; ?><br> </td> </tr> </tbody> </table> <br> <br> </body> </html>
Merci.