Forum

> > CS2D > Scripts > Removing something from a table
Forums overviewCS2D overview Scripts overviewLog in to reply

English Removing something from a table

2 replies
To the start Previous 1 Next To the start

old Removing something from a table

Surplus
User Off Offline

Quote
Didnt think i would need this before, but now i do.

1
abc={1,2,4,5,7,8,9}

For an example, how can i remove the 7 from the table?

old Re: Removing something from a table

EngiN33R
Moderator Off Offline

Quote
The function is
1
table.remove(table,key)

I use the following code to find the key of a table item (may not be the most efficient one):

1
2
3
4
5
6
7
8
function findByKey(table,element)
	for key,item in ipairs(table) do
		if element==item then
			return key
		end
	end
	return nil
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview