Valid XHTML     Valid CSS2    

Listing du fichier logement.php

 

00001     <?php
00002     
00003     error_reporting
(E_ALL | E_NOTICE | E_STRICT) ;
00004     
00005     
# chargement de fonctions usuelles pour le Web,
00006     # voir http://www.info.univ-angers.fr/~gh/internet/stdphp.php
00007     # pour plus de détails
00008     
00009     
include_once(
"std.php") ;
00010     
00011     
#######################################################################################
00012     
00013     
function
tableauFichier($fn,$dec="") {
00014     
00015     
#######################################################################################
00016     
00017     #
00018     # cette fonction affiche sous forme de tableau HTML un fichier .dar
00019     # le paramètre $dec contient un codage pour chacune des colonnes :
00020     # L pour justification à gauche
00021     # C pour justification centrée
00022     # x (numérique) pour justification à droite avec x décimales
00023     
00024     
if (!
file_exists($fn)) {
00025     
h3
(" Fichier $fn non vu") ;
00026     } else {
00027     
$fh
= fopen($fn,"r") ;
00028     
table
(1,10,"collapse") ;
00029      echo
"\n" ;
00030     
$nbl
= 0 ;
00031      while (!
feof
($fh)) {
00032     
$lig
= fgets($fh, 4096) ;
00033      if (
strlen
(trim($lig))>0) {
00034     
$nbl
++ ; tr() ;
00035      if (
$nbl
==1) {
00036     
$entete
= preg_split("/\s+/",(trim($lig))) ;
00037      foreach (
$entete
as $idc) {
00038     
th
("C","","","",0) ; echo $idc ; finth() ;
00039      } ;
# fin pour chaque
00040     
} else {
00041     
$lignorm
= preg_split("/\s+/",(trim($lig))) ;
00042     
$jdc
= -1 ;
00043      foreach (
$lignorm
as $idc) {
00044     
$jdc
++ ; $cdf = substr($dec,$jdc,1) ; $mef = $cdf ; $vdc = $idc ;
00045      if (
is_numeric
($cdf)) {
00046     
$mef
= "R" ; $vdc = sprintf("%0.".$cdf."f",$idc) ;
00047      } ;
# fin si
00048     
cmt
($mef) ;
00049     
td
($mef,"","","",0) ; echo $vdc ; fintd() ;
00050      } ;
# fin pour chaque
00051     
} ; # fin si
00052     
fintr() ;
00053      } ;
# fin si
00054     
} ; # fin tant que
00055     
fintable() ;
00056     } ;
# fin si
00057     
00058     
} ; # fin de fonction tableauFichier
00059     
00060     #######################################################################################
00061     
00062     
tableauFichier
("logement.txt","L".copies("2",10)) ;
00063     
00064     
?>

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)