http://www.php.net/manual/en/function.implode.php
for your example, I guess it would look like this.
$q3str = implode("~", $q3);
if $q3 is an array and contains the following example data
"test1,test2,test3,test4"
where
$q3[1]=test1
$q3[2]=test2
$q3[3]=test3
$q3[4]=test4
then $q3str would look like this "test1~test2~test3~test4"
you could then parse through the string pulling out the values and then code to insert them into the database.