• Get table index using string
    3 replies, posted
so lets say i have this table Table={ "Some", "Bananas", "on", "Trees", } and i want to remove Bananas but the list might be alot larger. what would be the solution to get the index. to find it using a string?
Multiple ways to do: (Easiest) table.RemoveByValue(Table, "Bananas") --Remove the first index found equal to "Bananas" (Harder) local table.KeyFromValue( Table, "Bananas" ) --Get the first index of "Bananas" found. table.Remove(Table, index) --Remove val from index.
local function removeByValue(tbl, val) for i = 1, #tbl do if tbl[i] != val then continue end tbl[i] = nil end end fatser method for arrays
Your way worked thank you
Sorry, you need to Log In to post a reply to this thread.