Expression Régulière: Trouver une chaîne dans un fichier

Author:


Download

<html>
<head>
<title>Expression régulière</title>
</head>
<body>

<?php

// Ce programme Affiche le Titre d''un Site web

$fichier = fopen("http://127.0.0.1/home/", "r");

if (!$fichier)
{
    echo "<p>Impossible d'ouvrir le lien";
    exit;
}
while (!feof($fichier))
{
 // Lire le fichier ligne par ligne

    $ligne = fgets($fichier, 1024);

    if (ereg("<title>(.*)</title>", $ligne, $regs))
    {
        $titre = $regs[1];
        echo $titre."<br/>";
        break;

    }
}
fclose($fichier);
?>

</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 6 = seven