PHP - Fonction fnmatch ()

La fonction fnmatch () compare le nom de fichier ou la chaîne à un modèle spécifié.

Syntaxe

bool fnmatch ( string $pattern , string $string [, int $flags = 0 ] )

La fonction fnmatch () peut vérifier si la chaîne transmise peut correspondre au modèle générique de shell donné, et cette fonction n'a pas été implémentée sur les plates-formes Windows.

Exemple

<?php
   $color = "phpcodez.txt";
   if(fnmatch("*phpcode[zs].txt", $color)) {
      echo "phpcodez";
   } else {
      echo "Color not found!";
   }
?>

Production

phpcodez