From: Paul Mckibbin Date: 2008-03-26T00:56:45+09:00 Subject: Re: multi-dimentional array Joan Gu wrote: > I need to insert Broad Category value and Topics value into a table, > doing something like this (where 'Police, Crime, Drugs' are topics > values and 'Crime & Law Enforcement' is broad category value): How about using a hash with arrays underneath? Something like: category_hash={} cat1 = 'Crime & Law Enforcement' cat2 = 'Emergency Management' obj1 = 'Police, Crime, Drugs' obj2 = 'Fire, Emergency Services' category_hash[cat1]= obj1.split(",").map {|s| s.strip} category_hash[cat2]= obj2.split(",").map {|s| s.strip} You can then add new items like this: category_hash[cat1] << 'New Crime related item' puts category_hash.inspect #=>{"Emergency Management"=>["Fire", "Emergency Services"], "Crime & Law Enforcement"=>["Police", "Crime", "Drugs", "New Crime related item"]} and you can then iterate through categories and within each category through the items. Mac -- Posted via http://www.ruby-forum.com/.