View Single Post

  #3 (permalink)  
Old 07-07-2004
Justin Koivisto
 
Posts: n/a
Default Re: Writing array to csv string

Adam Levenstein wrote:

> Hey all,
>
> I have need to take an array of strings from a form and write it to a
> string (not a file) in csv format. Is there a quick n' easy way of
> doing this?
>
> Thanks,
>
> Adam


Something like the following should work...

$csv='';
foreach($array as $v)
$csv.=', \''.addslashes($v).'\'';
$cvs=substr($csv,2);

--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Reply With Quote