Skip to content

Instantly share code, notes, and snippets.

@marcosfreitas
Forked from gwobcke/checkIfInArray.asp
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save marcosfreitas/af80df6783e151d683ca to your computer and use it in GitHub Desktop.

Select an option

Save marcosfreitas/af80df6783e151d683ca to your computer and use it in GitHub Desktop.
Esta função em ASP serve para verificar se um determinado valog existe em um array. Retorna false se não encontrar nada ou retorna a posição (i) onde o valor foi encontrado
<%
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
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment