Skip to content

Instantly share code, notes, and snippets.

@gwobcke
Last active October 4, 2022 12:42
Show Gist options
  • Save gwobcke/1044367 to your computer and use it in GitHub Desktop.
Save gwobcke/1044367 to your computer and use it in GitHub Desktop.
Classic ASP Check If In Array
<%
Function in_array(element, arr, performTrim)
Dim i
in_array = False
For i=0 To Ubound(arr)
If performTrim Then '//there are some scenarios where you want to trim
If Trim(arr(i)) = Trim(element) Then
in_array = True
Exit Function
End If
Else '//and other scenarios where you don't
If arr(i) = element Then
in_array = True
Exit Function
End If
End If
Next
End Function
DIM findThis
findThis = "Apple"
fruits = Array("Banana","Apple","Orange")
If in_array(findThis, fruits, false) Then
Response.Write findThis & " is in the array"
Else
Response.Write findThis & " is not in the array"
End If
%>
@sergioruizdeveloper
Copy link

Thank you, It is very useful for my work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment