开发者

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

开发者 https://www.devze.com 2022-12-19 11:07 出处:网络
I am trying to figure out how to cr开发者_StackOverfloweate 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.

I am trying to figure out how to cr开发者_StackOverfloweate 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

}


fnmatch()


http://ca.php.net/manual/en/function.fnmatch.php

0

精彩评论

暂无评论...
验证码 换一张
取 消