How to read multiple values from select list

I have a select box that allows multiple values to be selected.

<select class="element select medium" id="songcategory" name="songcategories[]" size="5" multiple="multiple"> 
<option value="1---Apple">Apple</option>
<option value="2---Banana">Banana</option>
<option value="3---Orange">Orange</option>
<option value="4---Melon">Melon</option>


The form is submitted via POST. I am using the PHP code below to read all the selected options. However, I only get a SINGLE value returned - the last option selected. No array of options, zilch! Iā€™m stumped - any ideas?

if ($_POST['songcategories']) {
	foreach ($_POST['songcategories'] as $c) {
		$c_array = explode("---",ucwords($c));
		$categoryid = $categoryid . "," . $c_array[0];
		$categoryname = $categiryname . "," . $c_array[1];

Ok, sorted out - this was a SQL error where the data was getting written, the field in question was an int and would only store the value of one option not the csv string I was building.

Moderators: Please close this thread, thanks.

Ok figured out a typo in the php:

$categoryname = $categoryname . ā€œ,ā€ . $c_array[1];

I get a csv for the $categoryname, but the $categoryid is always just the one number. Help!