ASP VbScript – is in array

Problem: saznati je li element unutar array-a

Rješenje:

https://gist.github.com/gwobcke/1044367

<%
Function in_array(element, arr)
  in_array = False
  For i=0 To Ubound(arr)
     If Trim(arr(i)) = Trim(element) Then
        in_array = True
        Exit Function
     End If
  Next
End Function

findThis = "Apple"
fruits = Array("Banana","Apple","Orange")

If in_array(findThis, fruits) Then
  Response.Write findThis & " is in the array"
Else
  Response.Write findThis & " is not in the array"
End If
%>

Comments are closed.