Current Location: Home> Function Categories> fnmatch

fnmatch

Match file names with pattern
Name:fnmatch
Category:File system
Programming Language:php
One-line Description:Match file names or strings according to the specified pattern.

Example

Check the color name according to the shell wildcard:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token variable">$txt</span> <span class="token operator">=</span> <span class="token string double-quoted-string">"My car is darkgrey..."</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span> <span class="token function">fnmatch</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"*gr[ae]y"</span> <span class="token punctuation">,</span> <span class="token variable">$txt</span> <span class="token punctuation">)</span> <span class="token punctuation">)</span>
  <span class="token punctuation">{</span>
  <span class="token keyword">echo</span> <span class="token string double-quoted-string">"some form of gray..."</span> <span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token delimiter important">?></span></span>
Similar Functions
  • Rename a file or directory rename

    rename

    Renameafileordirecto
  • Modify all groups of symbolic links lchgrp

    lchgrp

    Modifyallgroupsofsym
  • Test whether the file pointer reaches the end of the file feof

    feof

    Testwhetherthefilepo
  • Change the group to which the file belongs chgrp

    chgrp

    Changethegrouptowhic
  • Read a line from a file pointer fgets

    fgets

    Readalinefromafilepo
  • Return the target of the symbolic link readlink

    readlink

    Returnthetargetofthe
  • Format input from a file fscanf

    fscanf

    Formatinputfromafile
  • Change file owner chown

    chown

    Changefileowner
Popular Articles