Match a filename or string against the specified pattern in PHP

Description

The following code shows how to match a filename or string against the specified pattern.

Example


//from w w w  .  j  ava2s.c o  m
<?php
    $txt = "Sky is darkgrey...";
    if (fnmatch("*gr[ae]y",$txt)){
        echo "some form of gray ...";
    }
?>




















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone