How to have a array within a array

hi i am having problems figuring out how to put an array within an array,for example the primary array should look something like this:
[lua] array[1] = {name=“Garry”, ID=“12983”} [/lua]
so that you would be able to use [lua]
for _,a in pairs(names) do
if a.ID == steamid then
Msg("Player Has Been Found In Records!
if != ply:Name() then = ply:Name()
Found = true
to separate the primary array into each individual array stored in side it and get the stored name and id

You can have infinite table keys.


local examples = {
andd = {
more = {
examples = {
inside = {
of = {
a = {
table = {

local a = “”;
for k, v in pairs( examples[ andd ][ more ][ examples ][ inside ][ of ][ a ][ table ] ) do
a = a … " " … v;
print( a );
would output

why wont this work: [lua]
local temp_table = { ply = { username = “”, userid="" } }
temp_table[ply][userid] = string.gsub(c,“SteamID=”,"")
[/lua] it goves me the error: "attempt to index field ‘?’ (a nil value)
" any ideas as to what is wrong?

You havnt set the variable ‘c’ as anything, the error is actually

bad argument #1 to ‘gsub’ (string expected, got nil)

Actually, the problem is that he’s defining a table incorrectly.

Encase “ply” in square brackets when defining “temp_table”. You want the value of ply to be the key, not the name “ply”.

You can also do it this way :
[lua]local temp_table = {}
temp_table.ply = {1,45,64}[/lua]

That too

yay thanks for the help now another question when i input this string “EKS<@#^&*&gt;Dark&lt;@#^&*>Dragon” into this code [lua]
local lame = string.gsub(c,“Name=”,"")
Msg("Step 1 = “…lame)
local lame2 = string.gsub(lame, “<@#%^&*&gt;", " ") Msg(" Step 2 = "..lame2) name = string.gsub(lame2,"&gt;*&^%#@!<”, “=”)
Msg(” Step3 = “…name…”
[/lua] c being the inputted string i get the exact same thing as i put in back out why?

I’m not sure but I think it’s because your using the % in the second argument to gsub, so it’s interpreting it as a pattern.

try using

If it’s enclosed in “”'s it’s a string, so no need to recast it.