array in lua code example

Example 1: where do lua tables start

tbl = {"yes"}
tbl[1]
-- Arrays/Tables start at 1

Example 2: making an array lua

local Table = {"A", "B", "C", 1, 2, 3} -- Tables can have multiple value types.
print(Table[3]) -- Lua table indices start at 1 rather than 0.

Example 3: lua print all elements table

local people = {
   {
       name = "Fred",
       address = "16 Long Street",
       phone = "123456"
   },
   {
       name = "Wilma",
       address = "16 Long Street",
       phone = "123456"
   },
   {
       name = "Barney",
       address = "17 Long Street",
       phone = "123457"
   }
}

for index, data in ipairs(people) do
    print(index)

    for key, value in pairs(data) do
        print('\t', key, value)
    end
end