Richard Korts
asked on
Php error with an array
I have this code:
The last part of the output looks like the attached. Something is wrong with my array definition (I think)
Any help?
Array.JPG
$ckd_sels = array();
$nc = 0;
for ($i = 0; $i < $ns; $i++) {
$s = mysqli_fetch_array($ress,MYSQLI_ASSOC);
$cbnam = $s['pid'] . "-" . $s['ruid'] . "-" . $s['selno'];
$ck = "ck" . $cbnam;
echo "ck + cbnam = " . $ck . "<br>";
echo "checked = " . $_POST[$ck] . "<br>";
if ($_POST[$ck] == "on") {
echo "post-ck = " . $_POST[$ck] . "<br>";
$ckd_sels[$i] = $ck;
echo "ckdcells = " . $ckd_sels[$i] . "<br>";
$nc++;
}
}
echo "ckd_sels array = " . $ckd_sels . "<br>";
$_SESSION['ckdsels'] = $ckd_sels;
The last part of the output looks like the attached. Something is wrong with my array definition (I think)
Any help?
Array.JPG
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
You can't show an array using echo with concatenated string, you need to use :
Open in new window
If you want to show the content of an array inline you may need to convert it to string first using implode or json_encode.