alors que là$title = $out[1]
(empty($titre))
<?php 
$title = "";
$fichier = LE FICHIER A ANALYSER;  
if ($fp = @fopen( $fichier, 'r' )) {
   $cont = "";
   
   // read the contents
   while( !feof( $fp ) ) {
       $buf = trim(fgets( $fp, 4096 )) ;
       $cont .= $buf;
   }
   // get tag contents
   @preg_match( "/<title>([a-z 0-9]*)<\/title>/si", $cont, $match );
   
   // tag contents
   $title = strip_tags(@$match[ 1 ]); 
} 
?>
	mr_go a dit:Code:<?php $title = ""; $fichier = LE FICHIER A ANALYSER; if ($fp = @fopen( $fichier, 'r' )) { ..... [/quote] Bonjour On est bien d'accord qu'a la place de " LE FICHIER A ANALYSER " je marque le nom de mon fichier " Pub_Code_1_Art.php " par exemple ou est-ce que je me trompe ? merci et bonne journée :wink:
Ah!!! c'est là que ça doit poser probléme car sur certaine pages j'ai des liens avec la balise title pour les commenter. Est-ce un probleme ?
@preg_match( "/<title>...
	function get_file_title($file){
$cont = file_get_contents($file);
preg_match( "/<title>(.*)<\/title>/i", $cont, $match );
return strip_tags($match[0]); 
}
	mr_go a dit:Code:<?php $title = ""; $fichier = LE FICHIER A ANALYSER; if ($fp = @fopen( $fichier, 'r' )) { $cont = ""; // read the contents while( !feof( $fp ) ) { $buf = trim(fgets( $fp, 4096 )) ; $cont .= $buf; } // get tag contents @preg_match( "/<title>([a-z 0-9]*)<\/title>/si", $cont, $match ); // tag contents $title = strip_tags(@$match[ 1 ]); } ?>
Voilou![]()
Xou a dit:Code:<?php function get_file_title($file){ $cont = file_get_contents($file); preg_match( "/<title>(.*)<\/title>/i", $cont, $match ); return strip_tags($match[0]); } ?>
Xou a dit:pense à faire un:
pour ma fonctionCode:echo get_file_title("fichier.html");
et un:
pour le code de mr_goCode:echo $title;
![]()
➡️ Offre MyRankingMetrics ⬅️
        pré-audit SEO gratuit avec RM Tech (+ avis d'expert)
        coaching offert aux clients (avec Olivier Duffez ou Fabien Faceries)
    
Voir les détails ici