Skip to main content
Inspiring
October 4, 2007
Question

isArray

  • October 4, 2007
  • 4 replies
  • 554 views
I can't wrap my head around how to do this.

basically I want to check to see if the array exists

isarray(myarray)

But I also want to check to see if it is empty

????

If it is empty I want it to get caught in my conditional statement...Surely someone has an example.

Thanks,

Frank
    This topic has been closed for replies.

    4 replies

    Inspiring
    October 4, 2007
    > I found it in the WACk just now...

    Shouldn't that be the first step _before_ posting ;-)
    Inspiring
    October 4, 2007
    quote:

    Originally posted by: cf_dev2
    > I found it in the WACk just now...

    Shouldn't that be the first step _before_ posting ;-)

    Google is more efficient. Search strings like "coldfusion array functions" yield good answers quickly.
    Inspiring
    October 4, 2007
    quote:

    Originally posted by: Dan Bracuk
    Google is more efficient. Search strings like "coldfusion array functions" yield good answers quickly.



    Google is efficient, but if you already know you're looking for an array function the "Array Functions" section in either livedocs or CFWACK would seem the logical first step to me.

    Inspiring
    October 4, 2007
    Sounds like another name for ArrayLen() to me. Though to be fair, it may be more efficient than ArrayLen(). ie. checking for at least one element versus counting all elements.
    Inspiring
    October 4, 2007
    nope nope.....

    ArrayIsEmpty()

    I found it in the WACk just now...

    Frank

    Inspiring
    October 4, 2007
    > basically I want to check to see if the array exists
    > isarray(myarray)

    IsArray determines if the supplied value is an array, not whether the array exists.

    You can use IsDefined() to determine if your array variable exists. IsArray() to verify the variable is an array. ArrayLen() to determine if the array contains any elements. If the number of elements is 0, then array is empty.