I have a file index.php
from where I want to fill a <select>
with ciclo for
but I also want a default value to be selected.
I have done laravel
this exercise and it seemed as normal as possible, but I do not understand why in pure PHP it shows me the <select>
without values.
Laravel example, default value = 25
<select>
@for ($i = 18; $i <= 95; $i++)
<option @if ($i==25) selected
@endif
value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
Pure PHP, same example above
<?php
for ($i=18; $i<=95; $i++){
echo '<option'; if($i==25){ echo 'selected'; }'
value="'. $i.'">' . $i. '</option>';
}
?>
Does anyone see an error or give me an idea of what may be wrong? I appreciate any comment.
Perhaps