Reputation: 310
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.
Upvotes: 0
Views: 85
Reputation: 3400
Your "bug" must be coming from the line, the array merge is fine:
if ($_POST['running'] == 'yes')
Upvotes: 1