SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    London
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    If it's in an array

    Hi

    Is there a way of determining whether or not a value or values are present in an array.

    Is there something nice and easy as with php's

    if(in_array($SomeValue,$myArray)){
    echo "The value is here";
    }
    else{
    echo "The value is not here";
    }

    Thanks........and hope no one minds me writing a bit of php in this the asp section of the forum ;-)

    Juan

  2. #2
    HardCoder md_irfan_amu's Avatar
    Join Date
    May 2005
    Location
    Asia
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no function lik ePHP
    you have to write ur own and no shortcut, okay you have to find in the array byself function
    Irfan
    Find Tutors Easyway to get connect with your tutor in india

  3. #3
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Not true. You can use the isarray function:

    example:
    Code:
    <% If IsArray(arrvariable) Then %>
       array exists
    <%Else%>
       array doesn't exist
    <%End if%>
    reference:
    http://www.w3schools.com/vbscript/func_isarray.asp

  4. #4
    HardCoder md_irfan_amu's Avatar
    Join Date
    May 2005
    Location
    Asia
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for valuable info actually i was using then my own code

    Thanks
    Irfan
    Find Tutors Easyway to get connect with your tutor in india

  5. #5
    SitePoint Zealot
    Join Date
    May 2004
    Location
    London
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi thanks for these posts!

    I don't know if the IsArray function actually does what I need though.......

    basically I need to check whether one specific value is actually in the array as opposed to whether or not the variable itself is an array or not.........

    Any other ideas

    thanks very much

  6. #6
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know, there is no way to see if a string is in an array with ASP.


  7. #7
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'd need to either loop through the array searching for the string, or join the array and use the InStr function to look for a string within a string, something like:
    Code:
    Function InArray(arr, search)
    	If InStr(1, "^^" & Join(arr, "^^") & "^^", "^^" & search & "^^") > 0 Then
    		InArray = True
    	Else
    		InArray = False
    	End If
    End Function


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •