table example needed

Hi all, can anyone point me to an example of spawning a bunch of physics objects, putting them in a table and then retrieving one of them via its name? I know this sounds trivial but i have read through reams of info and havent gotten it to work.

edit : when i say retrieve, i mean retrieve the reference to that object by a name. [import]uid: 42417 topic_id: 16672 reply_id: 316672[/import]

local physics = require("physics")  
physics.start()  
  
local ground = display.newRect(0,460,320,20)  
physics.addBody(ground,"static")  
  
local arr = {}  
local i  
for i=1,10 do  
 local ph\_body = display.newCircle(100,100,20)  
 physics.addBody(ph\_body)  
 arr["item\_".. i] = ph\_body  
end  
  
print(arr["item\_5"].x)  
i = 3  
print(arr["item\_" .. i].x)  

cheers,

?:slight_smile:
[import]uid: 3826 topic_id: 16672 reply_id: 62303[/import]

for other readers, the code above works. my issue is (mostly) resolved, thank you! [import]uid: 42417 topic_id: 16672 reply_id: 62306[/import]