Why doesn't this code work when i call it via function? It only works for the outer loop but the inner loop does not return values?
<?php populateEnrollment($products); ?>
<?php
function populateEnrollment($value){
foreach($value as $productid => $prod) if ($productid ==101)
{
echo '<tr>';
echo '<td width=300 class="tah11">'. $prod["name"] .'</td>' ;
echo '<td width=100 class="tah11"><div align="center"> <select name="enrollName"id="enrollNameId" >';
foreach ($prod["membershipType"] as $type)
{
echo '<option value="' .$type["price"]; $typeIdPrice = $typeId["price"] .'">'.$type["name"] . ' at $' . $typeIdPrice . '</option>';
echo '</select>';
echo '</td>';
} // end of foreach membershipTypen
} // end of products foreach
} // end of function populateEnrollment
?>
print_r($prod["membershipType"]);to check whether it contains anythingprint_r($prod["membershipType"]);before starting inner loop.echo '<option value="' .$type["price"]; $typeIdPrice = $typeId["price"] .'">'.$type["name"] . ' at $' . $typeIdPrice . '</option>';this line is problematic. your <option> tag will never be closed like this.