<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.fnmatch.php',
    1 => 'fnmatch',
    2 => 'Match filename against a pattern',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Функції Файлової Системи',
  ),
  'prev' => 
  array (
    0 => 'function.flock.php',
    1 => 'flock',
  ),
  'next' => 
  array (
    0 => 'function.fopen.php',
    1 => 'fopen',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/filesystem/functions/fnmatch.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.fnmatch" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fnmatch</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">fnmatch</span> &mdash; <span class="dc-title">Match filename against a pattern</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fnmatch-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>fnmatch</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$pattern</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>fnmatch()</strong></span> checks if the passed <code class="parameter">filename</code> would
   match the given shell wildcard <code class="parameter">pattern</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.fnmatch-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">pattern</code></dt>
     <dd>
      <p class="para">
       The <code class="parameter">pattern</code> to match against. Usually, the <code class="parameter">pattern</code> will contain
       wildcards like <code class="literal">&#039;?&#039;</code> and <code class="literal">&#039;*&#039;</code>.
       <table class="doctable table">
        <caption><strong>
         Wildcards to be used in <code class="parameter">pattern</code> parameter
        </strong></caption>
        
         <thead>
          <tr>
           <th>Wildcard</th>
           <th>Опис</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>
            <code class="literal">?</code>
           </td>
           <td>
            Question mark will match any single character.
            For example, pattern <code class="literal">&quot;file?.txt&quot;</code> will match <code class="literal">&quot;file1.txt&quot;</code> and
            <code class="literal">&quot;fileA.txt&quot;</code>, but will not match <code class="literal">&quot;file10.txt&quot;</code>.
           </td>
          </tr>

          <tr>
           <td>
            <code class="literal">*</code>
           </td>
           <td>
            Asterisk will match zero or more characters.
            For example, pattern <code class="literal">&quot;foo*.xml&quot;</code> will match <code class="literal">&quot;foo.xml&quot;</code> and
            <code class="literal">&quot;foobar.xml&quot;</code>.
           </td>
          </tr>

          <tr>
           <td>
            <code class="literal">[ ]</code>
           </td>
           <td>
            Square brackets are used to create ranges of ASCII codepoints or sets of characters.
            For example, pattern <code class="literal">&quot;index.php[45]&quot;</code> will match <code class="literal">&quot;index.php4&quot;</code> and
            <code class="literal">&quot;index.php5&quot;</code>, but will not match <code class="literal">&quot;index.phpt&quot;</code>.
            Well known ranges are <code class="literal">[0-9]</code>, <code class="literal">[a-z]</code>, and <code class="literal">[A-Z]</code>.
            Multiple sets and ranges can be used at the same time, for example <code class="literal">[0-9a-zABC]</code>.
           </td>
          </tr>

          <tr>
           <td>
            <code class="literal">!</code>
           </td>
           <td>
            Exclamation mark is used to negate characters within square brackets.
            For example, <code class="literal">&quot;[!A-Z]*.html&quot;</code> will match <code class="literal">&quot;demo.html&quot;</code>, but will not match
            <code class="literal">&quot;Demo.html&quot;</code>.
           </td>
          </tr>

          <tr>
           <td>
            <code class="literal">\</code>
           </td>
           <td>
            Backslash is used to escape special characters.
            For example, <code class="literal">&quot;Name\?&quot;</code> will match <code class="literal">&quot;Name?&quot;</code>, but will not match
            <code class="literal">&quot;Names&quot;</code>.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       The tested string. This function is especially useful for filenames,
       but may also be used on regular strings.
      </p>
      <p class="para">
       The average user may be used to shell patterns or at least in their
       simplest form to <code class="literal">&#039;?&#039;</code> and <code class="literal">&#039;*&#039;</code>
       wildcards so using <span class="function"><strong>fnmatch()</strong></span> instead of
       <span class="function"><a href="function.preg-match.php" class="function">preg_match()</a></span> for
       frontend search expression input may be way more convenient for
       non-programming users.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       The value of <code class="parameter">flags</code> can be any combination of 
       the following flags, joined with the
       <a href="language.operators.bitwise.php" class="link">binary OR (|) operator</a>.
       <table class="doctable table">
        <caption><strong>
         A list of possible flags for <span class="function"><strong>fnmatch()</strong></span>
        </strong></caption>
        
         <thead>
          <tr>
           <th><code class="parameter">Flag</code></th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code><a href="filesystem.constants.php#constant.fnm-noescape">FNM_NOESCAPE</a></code></strong></td>
           <td>
            Disable backslash escaping.
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="filesystem.constants.php#constant.fnm-pathname">FNM_PATHNAME</a></code></strong></td>
           <td>
            Slash in string only matches slash in the given pattern.
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="filesystem.constants.php#constant.fnm-period">FNM_PERIOD</a></code></strong></td>
           <td>
            Leading period in string must be exactly matched by period in the given pattern.
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="filesystem.constants.php#constant.fnm-casefold">FNM_CASEFOLD</a></code></strong></td>
           <td>
            Caseless match. Part of the GNU extension.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fnmatch-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if there is a match, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fnmatch-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Checking a color name against a shell wildcard pattern</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">fnmatch</span><span style="color: #007700">(</span><span style="color: #DD0000">"*gr[ae]y"</span><span style="color: #007700">, </span><span style="color: #0000BB">$color</span><span style="color: #007700">)) {<br />  echo </span><span style="color: #DD0000">"some form of gray ..."</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.fnmatch-notes">
  <h3 class="title">Примітки</h3>
  <div class="warning"><strong class="warning">Увага</strong>
   <p class="para">
    For now, this function is not available on non-POSIX compliant systems
    except Windows.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.fnmatch-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.glob.php" class="function" rel="rdfs-seeAlso">glob()</a> - Find pathnames matching a pattern</span></li>
    <li><span class="function"><a href="function.preg-match.php" class="function" rel="rdfs-seeAlso">preg_match()</a> - Perform a regular expression match</span></li>
    <li><span class="function"><a href="function.sscanf.php" class="function" rel="rdfs-seeAlso">sscanf()</a> - Parses input from a string according to a format</span></li>
    <li><span class="function"><a href="function.printf.php" class="function" rel="rdfs-seeAlso">printf()</a> - Output a formatted string</span></li>
    <li><span class="function"><a href="function.sprintf.php" class="function" rel="rdfs-seeAlso">sprintf()</a> - Return a formatted string</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>