Advertisement
tw0phi

Untitled

Nov 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2.     if(!$monFichier = fopen('listeproduits/produits.txt', 'r'))
  3.     {
  4.         echo "Impossible d'ouvrir le fichier !<br/>";
  5.         exit();
  6.     }
  7.     else {
  8.         while(!feof($monFichier)){
  9.        
  10.             $ligne = fgets($monFichier);
  11.             $tligne = explode('|', $ligne);
  12.            
  13.             $nomProduit = $tligne[1];
  14.             $cheminImage = $tligne[2];
  15.             $prixProduit = $tligne[3] . ' €';
  16.            
  17.             echo 'Produit: ' . $nomProduit . '<br/>';
  18.             echo 'Prix: ' . $prixProduit . '<br/>';
  19.             echo '<img src="' . $cheminImage . '" height="150" width="150"/><br/>';
  20.         }
  21.         fclose($monFichier);
  22.     }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement