Jump to content

Forgot How To Delete An Array Element

Recommended Posts

Or to delete one element, just over write it.

Dim $x[3]




How to delete $x[2] ?


I think he means make it go away totally.

$x[0] = 3

$x[1] = 2

$x[2] = 1

Now delete $x[1] and you have this:

$x[0] = 3

$x[1] = 1

$x[2] = No longer exists, so it would be out of bounds.

BlueScreen, you have 2 options. One is to either check to make sure the element isn't empty before you act on it, this will allow you to use scriptkitty's solution of just assigning "" to the element. The other is to design some functions and stuff to implement your own container or something.

Link to post
Share on other sites
  • Administrators

Does that actually free the memory for the array, though?  The helpfile says $array = 0 will free it...

Assigning anything to the whole array will free it and turn in back into a single value.
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...