Click to See Complete Forum and Search --> : Problems with Array


cajo_vcambra
05-16-2003, 09:46 AM
Hi, Imagine this situation:

You have the following element of an array

array[0][3][4][3]

and you know that you have, for instance, 50 elements before this one. Knowing this number is there a way to represent the element shown above with a notation where i could use the #50?

khalidali63
05-16-2003, 10:00 AM
If I understadn your question correctly,if you put this array[0][3][4][3] an another array..:-)
then you can use that,,say you have an array that is indexed from 0 to 53 and 54th entry is the one above

someArray[54] = array[0][3][4][3];

this should work theoretically...

Charles
05-16-2003, 10:06 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<script type="text/javascript">
<!--
Array.prototype.toFlattened = function () {return this.toString().split(',')}

a1 = ['one', 'two', 'three', 'four'];
a2 = ['a', 'b', 'c', 'd'];
a = [a1,a2];
alert (a.toFlattened()[5])
// ->
</script>

cajo_vcambra
05-16-2003, 10:20 AM
It worked perfectly, thank you for your help (2 both).

:D