What is fnmatch in PHP Filesystem

In this article I am going to explain about fnmatch function in PHP.
  • 1403

PHP fnmatch() Function

The filesystem fnmatch function is used to matches a filename against a pattern.


Syntax of fnmatch function

fnmatch(fpattern, string,  flags)

Parameters in fnmatch  function

It have three parameter:

Parameter Description
pattern It specifies search pattern.
string It specifies string or file to check.
flags It is optional argument.

Example of filesystem fnmatch function

<html>

<body>

 

<?php

$str= "Life is a gift by God !";

if (fnmatch("*gr[ae]y", $str)) {

  echo "It is fnmatch function ...";

}

?>

 

</body>

</html>


You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.