par
nissou » 18 avr. 2015, 12:20
bonjour tout le monde ; j'ai un contenu dans un fichier texte que je voudrais afficher dans un tableau et le nom du fichier c'est le nom de page courante mais avec l'extension .txt ; j'ai essayé ce code mais il ne marche pas
<?php
$fichie = basename(__FILE__,'.php') ;
$fichier = "$fichie.txt";
$lignes = file($fichier);
echo '<table border="5" style="border-collapse:collapse;">';
echo '<tr>';
echo '<th>Produit</th>';
echo '<th>Prix</th>';
echo '<th>dispo</th>';
echo '<th>carac</th>';
echo '</tr>';
foreach($lignes as $ligne_num => $ligne) {
$array = explode('|', $ligne);
echo '<tr>';
echo '<td>'. $array[0] .'</td>';
echo '<td>'. $array[1] .'</td>';
echo '<td>'. $array[2] .'</td>';
echo '<td>'. $array[3] .'</td>';
echo '</tr>';
}
echo '</table>';
?>
bonjour tout le monde ; j'ai un contenu dans un fichier texte que je voudrais afficher dans un tableau et le nom du fichier c'est le nom de page courante mais avec l'extension .txt ; j'ai essayé ce code mais il ne marche pas
<?php
$fichie = basename(__FILE__,'.php') ;
$fichier = "$fichie.txt";
$lignes = file($fichier);
echo '<table border="5" style="border-collapse:collapse;">';
echo '<tr>';
echo '<th>Produit</th>';
echo '<th>Prix</th>';
echo '<th>dispo</th>';
echo '<th>carac</th>';
echo '</tr>';
foreach($lignes as $ligne_num => $ligne) {
$array = explode('|', $ligne);
echo '<tr>';
echo '<td>'. $array[0] .'</td>';
echo '<td>'. $array[1] .'</td>';
echo '<td>'. $array[2] .'</td>';
echo '<td>'. $array[3] .'</td>';
echo '</tr>';
}
echo '</table>';
?>