Results 1 to 2 of 2

Thread: array issue

  1. #1
    Join Date
    Dec 2011
    Thanked 0 Times in 0 Posts

    Default array issue

    Thanks in advance for your help!!!

    My issue is checking a array variable in a if statement to see if it empty.


    if pram(2) = "" then
    if empty redirect
    not empty run code
    end if

    This is how my array is created

    strString=Request.ServerVariables("HTTP_X_ORIGINAL _URL")
    strArray = split(strString, "/")
    Redim pram(uBound(strArray))
    For i = 0 to uBound(strArray)
    pram(i) = strArray(i)

    I can get empty array by

    if uBound(strArray) = -1 then

    But I want to check the second item in the array if it's empty. The first item in the array will exist but the second item may not exist and then I need the to redirect the user accordingly.

  2. #2
    Join Date
    Apr 2017
    Thanked 0 Times in 0 Posts


    be careful of using the If strMyArray(1) = "" condition to determine if your array is empty.

    first, this is actually checking the second element in the array. remember that arrays are zero-based! so if you really wanted to do this, it would have to be written as If strMyArray(0) = ""

    and the second reason to be careful using this, is that an empty string in one element doesn't necessarily mean that all other elements are empty too!

    Sorry! Noticed this is an old thread!
    Last edited by jojohan; 04-20-2017 at 07:00 AM. Reason: added comment

Similar Threads

  1. Replies: 3
    Last Post: 03-01-2012, 04:42 PM
  2. Resolved Please help! For loop and Explode($array) issue
    By olliepop in forum PHP
    Replies: 1
    Last Post: 10-06-2010, 10:16 AM
  3. Array Issue
    By thesprucegoose in forum JavaScript
    Replies: 1
    Last Post: 03-12-2009, 09:55 PM
  4. Array issue with MySQL. I'm about to die
    By janniesekind in forum PHP
    Replies: 0
    Last Post: 02-04-2009, 11:50 PM
  5. Replies: 5
    Last Post: 08-20-2007, 03:02 AM


Posting Permissions

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