我有一个包含所有路由/url及其路径的数组,
Example : $route = array(
'/' => 'files/index.php',
'pages' => 'files/pages.php',
'pages/add' => 'files/page-add.php',
'posts/*' => 'files/posts.php',
)
使用 array_key_exists() 我检查数组中是否存在路由,如果是,则加载其路径,如果找到直接匹配则它可以工作。
posts/*
每当向 发出请求时,我都希望它与路径匹配posts/anything, posts/view/10
,而我不能使用 array_key_exists() 来做到这一点。
你们对我应该使用哪种方法有任何想法/建议吗?