splicing non id arrays

ey everyone I need help with the following:

I have an array ...

array[506484] = blah
array[506688] = blah
array[506445] = blah

etc

those numbers are NOT array ids but identifiers... I need to remove some of them but when I use splice I think what's happenning is that the splice function is interpeting the nubmers as array IDS rather then textual ids... ie: for ( index in array )

any ideas? thanks guys
VFM-TechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
They ARE numeric indexes and not hash string associative indexes.
To make them associative indexes you have to add an alpha character to the key.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZvonkoSystems architectCommented:
To verify that the array has realy 506688 elements after upper assignments simply look for the array.length;
GwynforWebCommented:
to be sure the index is a number multiply it by 1  eg

<script>
 array=new Array('aa','bb','cc','dd','ee','ff')
 index='3'
 array.splice(1*index,1)
 alert(array)
</script>
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

ZvonkoSystems architectCommented:
Hello Gwyn, can you have a look at my calculation here: http:Q_21480616.html

And for here, no splice needed to remove an associative indexed element.
Simply delete it:

<script>
blah = "BLa Blah";
array = new Array();
array[506484] = blah
array[506688] = blah
array[506445] = blah

alert(array.length);

array["506484x"] = blah
array["506688x"] = blah
array["506445x"] = blah

alert(array.length);

delete array["506688x"];

alert(array.length);

array.length = 0;
for(i in array){
  alert(i+": "+array[i]);
}
</script>

cyboratCommented:
Is there a way to use slice() and splice() with an associative indexed array? I need to be able to swap 2 specific rows in an array that are not indexted by integers.
ZvonkoSystems architectCommented:
You cannot swap associative array elements. The entries are controlled by the associative index cache.
Andy if you want to change the associative keys, then you need a third key as helper key.
And the normal way is to open an own question for new requests.
cyboratCommented:
thanks Zvonko... I emulated it by doing a delete on the element i'm moving, then just rebuilding the array, and re-inserting the element at the row necesarry. Works fine. I was guessing the splice and slice would not work, but figured I'd ask here first just to make sure.

And sorry for the question here. I thought it was relevant to the question at hand (since VFM-Tech was thinking his were being evaluated as text indexes). Lesson learned ;)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.