I have an array and it looks like this.
[cuisine] => Array
(
[0] => 36
[1] => 12
[2] => 2
[3] => 4
[4] => 41
[5] => 22
)
So now I need to store these values in SESSION
. Something like this
$_SESSION['cuisine'] = 36, 12, 2, 4, 41, 22
This is how I tried it, But it doesn't work for me.
if (isset($_POST['cuisine'])) {
$cuisine = $_POST['cuisine'];
$noCuisine = count($cuisine);
if($noCuisine >= 1) {
$cuisines = '';
for($i=0; $i < $noCuisine; $i++) {
$cuisines .= $noCuisine[$i] . ", ";
}
echo $cuisines;
$_SESSION['cuisines'] = $cuisines;
} else {
$error_alert[] = "Please select at least one Cuisine.";
}
} else {
$error_alert[] = "Cuisine field can NOT be empty";
}
Can anybody tell me whats the wrong with this? Thank you