I have form for my recipe app that inserts ingredients into a db. If nothing has been submitted yet, nutritional values display '0'. Otherwise they update to the post values.
My structure for the nutritional display is:
Calories:
<?php if ($ingredientArray[calorieKey] >= 1)
echo $ingredientArray[calorieKey];
else echo 0; ?><br />
Protein:
<?php if ($ingredientsArray[proteinKey] >= 1)
echo $ingredientArray[proteinKey];
else echo 0; ?><br />
...and continues for about 20 items. The question is:
would it be more efficient to refactor the code using just 1 if/else statement to display 2 different forms (dynamic and static), or is it better as is?