• PHP Video Tutorials

PHP - Function fnmatch()



The fnmatch() function matches filename or string against a specified pattern.

Syntax

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

The fnmatch() function can check if the passed string could match the given shell wildcard pattern, and this function has not implemented on Windows platforms.

Example

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

Output

phpcodez
php_function_reference.htm
Advertisements