rhyspaterson Posted July 10, 2008 Share Posted July 10, 2008 Hey guys, I have an array as follows: var floor_array = new Array(5); for (var i = 0; i < 5; i++) { floor_array[i] = [' ', ' ', ' ']; } floor_array[0][0] = "ground"; floor_array[0][1] = "Printer Status - Ground Floor"; floor_array[0][2] = "Ground Floor"; floor_array[1][0] = "one"; floor_array[1][1] = "Printer Status - Level One"; floor_array[1][2] = "First Floor"; floor_array[2][0] = "two"; floor_array[2][1] = "Printer Status - Level Two"; floor_array[2][2] = "Second Floor"; floor_array[3][0] = "three"; floor_array[3][1] = "Printer Status - Level Three"; floor_array[3][2] = "Thrid Floor"; floor_array[4][0] = "four"; floor_array[4][1] = "Printer Status - Level Four"; floor_array[4][2] = "Fourth Floor"; Is there a quicker way to add all the data into array (the second section)? Or do i have to define each entry each time..? Was looking for something like: floor_array[0][] = "ground","Printer Status - Ground Floor","Ground Floor"; Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/114018-solved-javascript-and-multidimensional-arrays/ Share on other sites More sharing options...
Psycho Posted July 10, 2008 Share Posted July 10, 2008 Here you go: var floor_array = [ ["ground", "Printer Status - Ground Floor", "Ground Floor"], ["one", "Printer Status - Level One", "First Floor"], ["two", "Printer Status - Level Two", "Second Floor"], ["three", "Printer Status - Level Three", "Thrid Floor"], ["four", "Printer Status - Level Four", "Fourth Floor"] ]; Link to comment https://forums.phpfreaks.com/topic/114018-solved-javascript-and-multidimensional-arrays/#findComment-586022 Share on other sites More sharing options...
rhyspaterson Posted July 11, 2008 Author Share Posted July 11, 2008 Perfect, thanks mate! Link to comment https://forums.phpfreaks.com/topic/114018-solved-javascript-and-multidimensional-arrays/#findComment-587138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.