From: JacobC2 Date: 2008-01-25T05:24:56+09:00 Subject: Re: Mysql escape array On Jan 23, 3:37 pm, Thomas Wieczorek wrote: > Heya > > On Jan 23, 2008 6:49 PM, JacobC2 wrote: > > > I am writing a program that reads a text file and then dumps it into a > > mysql database, the problem that I am having is that the array has > > illegal characters in it so I need to do an escape_string or something > > on it. but how could I do this on an array? > > You can use map! or collect! or their non-destructive brothers map and > collect. collect/map apply a method to each element in the array and > return a new array with the results. > > # lines is some array > escaped = lines.map { |element| some_mysql_escape(element) } Thanks that work.