Php error with an array

I have this code:
$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;

Open in new window


The last part of the output looks like the attached. Something is wrong with my array definition (I think)

Any help?
Array.JPG
Richard KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
$ckd_sels is an array.  If you want to see its contents, try using implode:
echo "ckd_sels array = " . implode('; ', $ckd_sels) . "<br>";

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Zakaria AcharkiAnalyst DeveloperCommented:
Hi Richard,

You can't show an array using echo with concatenated string, you need to use :

echo $ckd_sels;
//Or
print_r($ckd_sels);

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.