Jump to content




Find String in Table


  • You cannot reply to this topic
2 replies to this topic

#1 Left

  • Members
  • 88 posts

Posted 22 March 2013 - 11:37 PM

I am having a mental BLANK. How can I find something in a table for example a randomally generated key which I have put in there.

#2 LordIkol

  • Members
  • 197 posts
  • LocationSwitzerland

Posted 23 March 2013 - 12:00 AM

This would give you the Place where the searched String is in the table.

local items = { "Hugo", "Karl", "Geerd", "Bananarama" }

for k, v in pairs(items) do
  if v == "Bananarama" then
	print(k)
break --delete this if there are multiple entries
  end
end

Greets Loki

#3 Left

  • Members
  • 88 posts

Posted 23 March 2013 - 12:08 AM

Thanks. Again about 2:30, I am tired. Goodnight! No moar dev for tonight. I may not be on until the 28th because I will not get my internet back until then!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users