Bonjour
voici mon problème,
je ne connais pas très bien explode et je m'embrouille.
J'ai un fichier "2012-07-rapport-ordres.log" sous cette forme
je souhaiterais les ranger dans des tableaux sous la forme suivante : :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 30/06/2012 -- 14:46:36 -- serveur -- cm15 E5 on -- minuterie.sh -- Aucun -- Script bash 30/06/2012 -- 14:48:28 -- serveur -- cm15 E5 on -- minuterie.sh -- Aucun -- Script bash 30/06/2012 -- 14:48:53 -- serveur -- cm15 E5 off -- minuterie.sh -- Aucun -- Script bash 30/06/2012 -- 16:04:59 -- serveur -- cm15 E5 on -- minuterie.sh -- Macro minuterie E5 on/off -- Script bash 30/06/2012 -- 18:53:25 -- serveur -- cm15 E1 on -- e1-15% -- Aucun -- Script bash 30/06/2012 -- 18:59:15 -- serveur -- cm15 E1 off -- e1-off -- Aucun -- Script bash 30/06/2012 -- 18:59:28 -- serveur -- cm15 E1 bri 15 -- e1-15% -- Aucun -- Script bash 30/06/2012 -- 19:03:25 -- serveur -- cm15 E1 bri 15 -- e1-15% -- Aucun -- Script bash 30/06/2012 -- 19:06:25 -- serveur -- cm15 E1 bri 15 -- e1-15% -- Aucun -- Script bash 30/06/2012 -- 19:08:12 -- serveur -- cm15 E1 off -- 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 E1 on -- e1-on -- Aucun -- Script bash 22/07/2012 -- 21:17:24 -- root -- cm15 E1 off -- e1-off -- Aucun -- Script bash 22/07/2012 -- 23:45:24 -- root -- cm15 D14 off -- d14-off -- Aucun -- Script bash 24/07/2012 -- 12:20:11 -- www-data -- cm15 D7 On -- b14-on -- Macro b14-on vers d7-on -- Script bash 24/07/2012 -- 12:20:30 -- www-data -- cm15 D7 Off -- b14-off -- Macro b14-off vers d7-off -- Script bash 24/07/2012 -- 13:19:19 -- www-data -- cm15 L4 On -- l4-on -- Macro l4-on vers f11-on -- Script bash 24/07/2012 -- 13:19:33 -- www-data -- cm15 L4 Off -- l4-off -- Macro l4-off vers f11-off -- Script bash 24/07/2012 -- 13:59:16 -- www-data -- cm15 E5 on -- e5-off -- Macro e5-on vers d8-on -- Script bash 24/07/2012 -- 13:59:44 -- www-data -- cm15 E5 off -- e5-off -- Macro e5-off vers d8-off -- Script bash 25/07/2012 -- 06:50:01 -- serveur -- cm15 D14 off -- D14-Off.sh -- Aucun -- Crontab 25/07/2012 -- 14:03:16 -- www-data -- cm15 E1 on -- e1-on -- Aucun -- Script bash 29/07/2012 -- 00:23:54 -- serveur -- cm15 E1 On -- e1-on -- Aucun -- Script bash 29/07/2012 -- 01:03:44 -- serveur -- cm15 E1 On -- e1-on -- Aucun -- Script bash 29/07/2012 -- 01:18:54 -- serveur -- cm15 E1 On -- e1-on -- Aucun -- Script bash 29/07/2012 -- 02:01:00 -- serveur -- cm15 E1 On -- e1-on -- Aucun -- Script bash 29/07/2012 -- 02:19:22 -- serveur -- cm15 E1 On -- e1-on -- Aucun -- Script bash
Code : Sélectionner tout - Visualiser dans une fenêtre à part date -- heure -- User -- Ordre X10 -- Fichier -- Macro -- executé par
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <?php // le fichier $fichier1 = '/home/serveur/Domotique/rapports/ordres/2012-07-rapport-ordres.log'; // 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 $date.=$position[0]; $heure.=$position[1]; $user.=$position[2]; $ordre_x10.=$position[3]; $fichier_exec.=$position[4]; $macro.=$position[5]; $execute_par.=$position[6]; } // fermeture du fichier fclose($fp); ?>Seulement il y a un problème avec les espaces dans le tableau,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 <table style="text-align: left; width: 800px;" 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: 1px;">User<br> </td> <td style="vertical-align: top; width: 80px;">Ordre x10<br> </td> <td style="vertical-align: top; width: 19px;">Fichier<br> </td> <td style="vertical-align: top; width: 91px;">Macro<br> </td> <td style="vertical-align: top; width: 100px;">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: 1px;"><br> </td> <td style="vertical-align: top; width: 80px;"><br> </td> <td style="vertical-align: top; width: 19px;"><br> </td> <td style="vertical-align: top; width: 91px;"><br> </td> <td style="vertical-align: top; width: 100px;"><br> --> </td> </tr> <tr> <td style="vertical-align: top; width: 19px;"><?php echo $date; ?><br> </td> <td style="vertical-align: top; width: 19px;"><?php echo $heure; ?><br> </td> <td style="vertical-align: top; width: 1px;"><?php echo $user; ?><br> </td> <td style="vertical-align: top; width: 80px;"><?php echo "". $ordre_x10 ."<br/ >"; ?><br> </td> <td style="vertical-align: top; width: 19px;"><?php echo $fichier_exec; ?><br> </td> <td style="vertical-align: top; width: 91px;"><?php echo $macro; ?><br> </td> <td style="vertical-align: top; width: 100px;"><?php echo $execute_par; ?><br> </td> </tr> </tbody> </table>
dans "user" il affiche uniquement "root root" au lieu de le mettre a la dessous ligne.
Dans "ordre X10" il v a à la ligne au lieu d'afficher sur une seule ligne "cm15 E1 On" ou "cm15 E1 bri 15" ??
Je ne trouve pas mon erreur ??
Comment dois-je faire ?
Merci.
?>
Partager