我是regex的新手。我试图检查参数与它的数据类型,并返回动态参数和数组中的原始路由。感谢您的帮助,可以帮助我迈出一小步。预先感谢。
$routes = array(
"admin",
"edit/{int:order_id}",
"u/{string:uname}",
"admin/edit/{int/id}"
);
$path = "edit/101";
function get_routes ( $routes, $path ) {
foreach ( $routes as $route ) {
if ( preg_split("[*{*:*}]", $route) == $path ) {
}
}
//returns order_id => 101 and the route 'edit/{int:order_id}'
}