Suppose I want to create a select box in PHP.
$months = array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
Option 1:
<select name="month">
<option value="">Month</option>
<option value="">-------</option>
<?php foreach ($months as $monthNum => $month) { ?>
<option value="<?php echo $monthNum+1 ?>"><?php echo $month ?></option>
<?php } ?>
</select>
Option 2:
<select name="month">
<option value="">Month</option>
<option value="">-------</option>
<?php
foreach (months() as $monthNum => $month)
echo '<option value="' . ($monthNum+1) . '">' . $month . "</option>\n";
?>
</select>
I personally think Option 1 renders the code harder to read and understand, at the same time Option 2 screws the indentation and puts more HTML into PHP.
Which option is preferred?
EDIT: I don't want to add another template engine on top of PHP, which is itself a template engine.