# Get (two-dimensional) array position

**URL:** <https://forum.kirupa.com/t/get-two-dimensional-array-position/62681>\
**Category:** Uncategorized\
**Created:** [August 30, 2004, 3:13pm UTC](https://forum.kirupa.com/t/get-two-dimensional-array-position/62681 "2004-08-30T15:13:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bape](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bape](https://forum.kirupa.com/u/bape)\
**Post date:** [August 30, 2004, 3:13pm UTC](https://forum.kirupa.com/t/get-two-dimensional-array-position/62681/1 "2004-08-30T15:13:19Z")

</div>

I found the tutorial about getting the index of something in an array, but i need the same for a twodimensional array, so i get [0][1] for example. How do i alter this code to do so?

```auto
Array.prototype.getIndex = function(data) {
 for (i=0; f=0; i<this.length; ++i; ) {
  if (this* == data) {
   return i;
  }
 }
 return -1;
}; 

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 30, 2004, 4:04pm UTC](https://forum.kirupa.com/t/get-two-dimensional-array-position/62681/2 "2004-08-30T16:04:33Z")

</div>

> [@bape](#):
>
> I found the tutorial about getting the index of something in an array, but i need the same for a twodimensional array, so i get [0][1] for example. How do i alter this code to do so?
> 
> ```auto
> Array.prototype.getIndex = function(data) {
> for (i=0; f=0; i<this.length; ++i; ) {
> if (this* == data) {
> return i;
> }
> }
> return -1;
> }; 
> 
> ```

maybe  
Array.prototype.getIndex = function(dat) {  
for (i=0; i\<this.length; i++) {  
for (j=0; j\<this\*.length; j++) {  
if (this\*[j] == dat) {  
trace(i+" "+j);  
}  
}  
}  
};
