If I have a variable:
$q3val = $q3[$i];
and I have another variable:
$q3str = $q3val . "~";
I'm trying to take each value in the $q3 array and seperate it with a ~. How can I do this?
If I have a variable:
$q3val = $q3[$i];
and I have another variable:
$q3str = $q3val . "~";
I'm trying to take each value in the $q3 array and seperate it with a ~. How can I do this?
Here's how I did something similar in one of my php scripts.
$Variable= $Variable1. "," .$Variable2;
that would work if my variable wasn't an array. How do I do it with my array?
how about something like this?
$string = implode("~", $array);
That will take the entire array, seperate it by ~ or whatever you include in there and hold it in the string variable.
I'm just learning PHP as well, so I may not be able to help out like you need. I just found the implode function helped me out a lot in my script where I wanted to parse an array with comma seperated values.
but that then makes my q3str an array, and I need to split it out into sepearate values seperated by ~ to insert into a database row.
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.
you forgot implode
$q3str = implode("~", $q3);