lua移除数组中指定key的值函数。
removeElementByKey(tbl,key)
local function removeElementByKey(tbl,key) local tmp ={} for i in pairs(tbl) do table.insert(tmp,i) end local newTbl = {} local i = 1 while i <= #tmp do local val = tmp [i] if val == key then table.remove(tmp,i) else newTbl[val] = tbl[val] i = i + 1 end end return newTbl end
function removeElementByKey(tbl,key)