【发布时间】:2016-04-22 13:00:05
【问题描述】:
我正在尝试检查变量的值是否在数组中。有一些困难。我的数组存储在 global.asa 中。
Dim aTree(5)
aTree(0) = "a"
aTree(1) = "b"
aTree(2) = "c"
aTree(3) = "d"
aTree(4) = "e"
aTree(5) = "f"
Application("aTree") = aTree
我要检查的变量存储了一些 html 内容
<% If tree = "a" Then %>
<div class="card bg_white">
<h1 class="bold small-caps tbrown">my content</h1>
</div>
<% End If %>
我正在尝试以这种方式进行检查
<% tree = Request("tree")
if in_array(tree, aTree) then %>
You've found it
<% End if %>
我有这个可以运行的笨重版本
(tree <> "" and tree <> "a" and tree <> "b" and tree <> "c" and tree <> "d" and tree <> "e" and tree <> "f")
但我想要一种更优雅的方式来使用数组。
帮助不大。谢谢。
【问题讨论】:
标签: arrays variables asp-classic