$cat[] = $_POST['cat'];
$cs = implode(",", $cat);
echo "1: " . $cs[0] . "<br>2: " . $cs[1];
Its splitting it by character, not by each answer
| SitePoint Sponsor |
$cat[] = $_POST['cat'];
$cs = implode(",", $cat);
echo "1: " . $cs[0] . "<br>2: " . $cs[1];
Its splitting it by character, not by each answer





Try...
PHP Code:$cs = implode(",", $_POST['cat']);
echo "1: " . $cs[0] . "<br>2: " . $cs[1];
Community Guidelines | Community FAQ
"He that is kind is free, though he is a slave;
he that is evil is a slave, though he be a king." - St. Augustine
nope





Shouldn't you use explode, anyways? You mention that you want to split, and implode is for joining.
Community Guidelines | Community FAQ
"He that is kind is free, though he is a slave;
he that is evil is a slave, though he be a king." - St. Augustine
Toly is right. Implode is for joining. So in this, cs is now a string instead of the array you want.
Why don't you just output $cat[0] and $cat[1] and delete that line where $cs = implode(",",$cat)?
That should do the trick.
I managed it once and cannot remember how now.
$cs[0] brings out the first letter of the string. Not the first string in the array.
Bookmarks