RobKohr
RobKohr

Reputation: 6943

Need a way to check to see if a wildcard string matches a given string in PHP

I am trying to figure out how to create a function where I can pass in two strings, one with wildcards and another that is checked to see if it matches the wildcard string.

$wildcard_string = '*.example.com/some/path/*';
$test_string = 'dev.example.com/some/path/art123.html';

function test_wildcard_match($wildcard_string, $test_string){

  //return true or false

}

Upvotes: 1

Views: 199

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798814

fnmatch()

Upvotes: 7

Related Questions