我正在尝试在没有任何参数的情况下在Javascript中提取当前文件名.
$(location).attr('href').match(/([a-zA-Z\-\_0-9]+\.\w+)$/);
var current_path = RegExp.$1;
if ((current_path == 'index.html') || ...) {
// something here
}
Run Code Online (Sandbox Code Playgroud)
但是当您访问http://example.com/index.html?lang=ja时,它根本不起作用.当然,文件名将随机更改.
任何的想法?
在php中,我愿意检查是否存在与数组中的其他值匹配的索引.
$indexes = array("index", "id", "view");
$fields = array(
"index" => 5,
"id" => 7,
"form" => 10,
"date" => 10,
);
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我的理想结果是获得"形式"和"约会".任何的想法?