28,391
社区成员
发帖
与我相关
我的任务
分享
'查询是否存在该值
Function seekArrayVal(strArr,strVal)
Dim strBool:strBool=false
If Not IsArray(strArr) Or strVal="" then seekArrayVal=strBool
For Each tmp in strArr
If strVal=tmp then
strBool=true
Exit For
End If
Next
seekArrayVal=strBool
End Function
<%
'返回值在数组中的下标
Function getArrayIndex(strArr,strVal)
Dim strIndex,J
If NOT IsArray(strArr) Or strVal="" then strIndex=-1
For J=0 to UBound(strArr)
If IsNumeric(strVal) then
If Int(Abs(strVal))-strArr(J)=0 then strIndex=J
ElseIf IsObject(strVal) Or IsDate(strVal) Or IsArray(strVal) then
strIndex=-1
Else
If Trim(strVal)=strArr(J) then strIndex=J
End If
Next
getArrayIndex=strIndex
End Function
Dim a:a="abc|ab|efg|hi"
Dim b:b="ab"
Response.Write Split(a,"|")(getArrayIndex(Split(a,"|"),b)) &"<br/>"
Response.Write getArrayIndex(Split(a,"|"),b)
%>