<?php

// ------------------------------------------------------------------------- //
// Lire la ligne n d'un fichier                                              //
// ------------------------------------------------------------------------- //
// Auteur: Matt <matt@php-test.com>                                          //
// Web:    http://www.php-test.com                                           //
// ------------------------------------------------------------------------- //

/*
Cette fonction vous permettra de lire la ligne $ligne du fichier $fichier.

Exemple d'utilisation:

    echo Lire_La_Ligne_n("data.txt" , "2");
    => affichera la ligne 2 du fichier data.txt
*/

function Lire_La_Ligne_n($fichier, $ligne)
{
    if (
file_exists("$fichier"))
    {
        if(
$id = fopen("$fichier", "r+"))
            {
            while(!
feof($id))
            {
                
$result[]= fgets($id,1000000);
            }
            
fclose($id);
            
$tab=$result;
            
$result=$tab[$ligne-1];
            return
$result;
        }
        else
        {
            return
pb_ouv;
        }
    }
    else
    {
        return
no_file;
    }
}

?>