the following produces no output, when really it should show a list including Milk, Cheese and Yoghurt. It is probably something really simple, I just can't see it.
<?php
$FoodList=array();
$newArray =array();
echo "<p>";
$Dairy= array(
'a' => 'Milk',
'b' => 'Cheese',
'c' => 'Yoghurt',
);
$Fruit = array(
'd' => 'Apples',
'e' => 'Oranges',
'f' => 'Grapefruit',
);
$GlutenFree = array(
'g' => 'GF Cookies',
'h' => 'GF Pancakes',
'i' => 'GF Bread',
);
$Sweets = array(
'j' => 'Musk Sticks',
'k' => 'Caramels',
'l' => 'Chocolate',
);
if ($_POST['running'] == 'yes')
{
$newArray = array_merge($FoodList, $Dairy);
foreach ($newArray as $key => $value)
{
echo $value;
}
}
echo "<p>";
?>
This may because the FoodList Array does not have anything in it, so I will look into that, but I have a strong feeling it is related to something else.
$newArray? Useprint_r( $newArray )to see what's in it.$newArrayis an empty array. Also I've tried your code and it works perfectly. Maybe the$_POST['running']!== 'yes'?$Running=$_POST['Running'];then you should be checking if it'struemeaning if it has been checkedif ($_POST['Running'] == true)and your input should be<input type="checkbox" name="Running" />so when it's checked, it will returnMilkCheeseYoghurtand nothing if it isn't checked.